Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: There is huge potential to improve further

Author: Gerd Isenberg

Date: 11:24:52 07/11/03

Go up one level in this thread


>These are all very fascinating, but after testing them all, it seems that a
>16-bit lookup table is still the fastest on my Athlon. Probably the bsf method
>will be fastest on a P3.

Yes, absolutely.
In IsiChess on XP2.8+ Barton unconditional bsf is fastest now.

__asm
{
	mov		edx, [bb]
	bsf		eax, [edx+4]
	xor		eax, 32
	bsf		eax, [edx]
	btr		[edx],eax
}

What about this one with the (bb ^ (bb - 1)) idea?

const int 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,
};


int bitScanAndReset(BitBoard &bb)
{
	BitBoard lsb = bb ^ (bb - 1);
	bb &= ~lsb;
	unsigned int foldedLSB = ((int) lsb) ^ ((int)(lsb>>32));
	return lsz64_tbl[foldedLSB * 0x78291ACF >> 26];
}

Gerd



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.