]> git.sesse.net Git - stockfish/commitdiff
Micro optimization in evaluate_pawns()
authorMarco Costalba <mcostalba@gmail.com>
Fri, 14 May 2010 11:51:29 +0000 (12:51 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 14 May 2010 11:59:03 +0000 (12:59 +0100)
Avoid a double bitcount in test for candidate passed
pawn when we don't have any supporting pawn.

Also use outpost_mask() instead of build it up on
the fly.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/pawns.cpp

index 0ccfe809a1dcfb806406887098a62a6945dbee77..c2d60e4b4b3b30b65b29f79d4c02e5711642b4db 100644 (file)
@@ -252,12 +252,12 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
           backward = (b | (Us == WHITE ? b << 8 : b >> 8)) & theirPawns;
       }
 
+      assert(passed | opposed | (outpost_mask(Us, s) & theirPawns));
+
       // Test for candidate passed pawn
-      candidate =   !passed
-                 && !opposed
-                 && (  count_1s_max_15(neighboring_files_bb(f) & (behind_bb(Us, r) | rank_bb(r)) & ourPawns)
-                     - count_1s_max_15(neighboring_files_bb(f) & in_front_bb(Us, r)              & theirPawns)
-                     >= 0);
+      candidate =   !(opposed | passed)
+                 && (b = outpost_mask(opposite_color(Us), s + pawn_push(Us)) & ourPawns) != EmptyBoardBB
+                 &&  count_1s_max_15(b) >= count_1s_max_15(outpost_mask(Us, s) & theirPawns);
 
       // In order to prevent doubled passed pawns from receiving a too big
       // bonus, only the frontmost passed pawn on each file is considered as