X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=cf6846384e6e04138e4000cfabbaeb5cea0c3ad9;hp=9756add8278d01fd5fece9ac98fe620a255ab2ce;hb=9d1151575ddf3219c1ee157fe7a8336764e825ec;hpb=3cf6471738dc704ddf553d5f8d2dc9875c2ccbe7 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 9756add8..cf684638 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1146,7 +1146,11 @@ Value do_evaluate(const Position& pos, Value& margin) { behind |= (Us == WHITE ? behind >> 8 : behind << 8); behind |= (Us == WHITE ? behind >> 16 : behind << 16); - return popcount(safe) + popcount(behind & safe); + // Since SpaceMask[Us] is fully on our half of the board + assert(unsigned(safe >> (Us == WHITE ? 32 : 0)) == 0); + + // Count safe + (behind & safe) with a single popcount + return popcount((Us == WHITE ? safe << 32 : safe >> 32) | (behind & safe)); }