Author: Gerd Isenberg
Date: 06:05:11 05/10/05
Go up one level in this thread
>I think I recall that the deBruijn trick was rather fast on the G4 as well, >but I am not entirely sure. Dieter once posted a slightly more complicated >version optimized for 32-bit CPUs. It can probably still be found somewhere >in the archives. > I guess Matt Taylor's folding trick: int bitScanWithReset(BitBoard &bb) { static const unsigned int CACHE_ALIGN lsz64_tbl[64] = { 63,30, 3,32,59,14,11,33, 60,24,50, 9,55,19,21,34, 61,29, 2,53,51,23,41,18, 56,28, 1,43,46,27, 0,35, 62,31,58, 4, 5,49,54, 6, 15,52,12,40, 7,42,45,16, 25,57,48,13,10,39, 8,44, 20,47,38,22,17,37,36,26, }; BitBoard b = bb ^ (bb - 1); bb = bb & (bb - 1); // only one further and unsigned int fold = ((int) b) ^ ((int)(b>>32)); return lsz64_tbl[(fold * 0x78291ACF) >> (32-6)]; }
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.