Author: Uri Blass
Date: 12:43:02 04/18/03
Go up one level in this thread
On April 18, 2003 at 15:11:34, Dieter Buerssner wrote: >On April 18, 2003 at 03:17:52, Gerd Isenberg wrote: > >>static __forceinline int _fastcall BitCount8 (BitBoard bb) >>{ >> __asm >> { >> mov ecx, dword ptr bb >> xor eax, eax >> test ecx, ecx >> jz l1 >> l0: lea edx, [ecx-1] >> inc eax >> and ecx, edx >> jnz l0 >> l1: mov ecx, dword ptr bb+4 >> test ecx, ecx >> jz l3 >> l2: lea edx, [ecx-1] >> inc eax >> and ecx, edx >> jnz l2 >> l3: >> } >>} > >Gerd, did you check, if this is really faster than corresponding C-code? > >int PopCount(BITBOARD a) >{ > unsigned long w; > int n = 0; > w = *(unsigned long *)&a; > if (w) > do > { > n++; > } > while ((w &= w-1) != 0); > w = *(((unsigned long *)&a)+1); > if (w) > do > { > n++; > } > while ((w &= w-1) != 0); > return n; >} I simply use the following function that seem to be faster and was copied from crafty if I remember correctly(I changed BITBOARD to BitBoard because originally I used BitBoard in my defines and I saw no reason to change all the letters to big letters). If I replace it by your function my code run slower. Note that I get 0 in most of the cases that I call PopCount. int PopCount(register BitBoard a) { register int c=0; while(a) { c++; a &= a - 1; } return(c); } Uri
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.