]> git.sesse.net Git - stockfish/commitdiff
Small speed-up in BetweenBB
authorprotonspring <mike@whiteley.org>
Tue, 3 Mar 2020 23:35:45 +0000 (16:35 -0700)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sat, 7 Mar 2020 09:48:16 +0000 (10:48 +0100)
A speed-up removing some comparisons.

closes https://github.com/official-stockfish/Stockfish/pull/2571

No functional change.

src/bitboard.h

index ca161481c4594e7b191f4fdf5730829b1c4c5bdf..b0e272338c0f536f95067a4f34747ba6e714b22f 100644 (file)
@@ -199,8 +199,8 @@ inline Bitboard adjacent_files_bb(Square s) {
 /// If the given squares are not on a same file/rank/diagonal, return 0.
 
 inline Bitboard between_bb(Square s1, Square s2) {
-  return LineBB[s1][s2] & ( (AllSquares << (s1 +  (s1 < s2)))
-                           ^(AllSquares << (s2 + !(s1 < s2))));
+  Bitboard b = LineBB[s1][s2] & ((AllSquares << s1) ^ (AllSquares << s2));
+  return b & (b - 1); //exclude lsb
 }