]> git.sesse.net Git - stockfish/commitdiff
Micro-optimize pop_lsb() for 64bit case
authorMarco Costalba <mcostalba@gmail.com>
Thu, 1 Nov 2012 08:30:03 +0000 (09:30 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 2 Nov 2012 11:11:49 +0000 (12:11 +0100)
On Intel, perhaps due to 'lea' instruction this way of
zeroing the lsb of *b seems faster than a shift+negate.

On perft (where any speed difference is magnified) I
got a 6% speed up on my Intel i5 64bit.

Suggested by Hongzhi Cheng.

No functional change.

src/bitboard.h

index b99cc2597ceb7959709b50c1dbfa3514e2479383..35904377ea62d633f55adc83b749b55f8e8f85a7 100644 (file)
@@ -280,7 +280,7 @@ FORCE_INLINE Square msb(Bitboard b) {
 
 FORCE_INLINE Square pop_lsb(Bitboard* b) {
   const Square s = lsb(*b);
 
 FORCE_INLINE Square pop_lsb(Bitboard* b) {
   const Square s = lsb(*b);
-  *b &= ~(1ULL << s);
+  *b &= *b - 1;
   return s;
 }
 
   return s;
 }