mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Micro-optimization in evaluate_space()
Since &-ing with SpaceMask restricts the set to the home half of the board, it is possible to use just one popcount instead of 2 by shifting "safe" to the other half of the board. This gives a small speedup especially on systems where hardware popcount is not available. Patch kindly sent by Richard Vida. No functional change.
This commit is contained in:
@@ -1146,7 +1146,11 @@ Value do_evaluate(const Position& pos, Value& margin) {
|
|||||||
behind |= (Us == WHITE ? behind >> 8 : behind << 8);
|
behind |= (Us == WHITE ? behind >> 8 : behind << 8);
|
||||||
behind |= (Us == WHITE ? behind >> 16 : behind << 16);
|
behind |= (Us == WHITE ? behind >> 16 : behind << 16);
|
||||||
|
|
||||||
return popcount<Max15>(safe) + popcount<Max15>(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<Full>((Us == WHITE ? safe << 32 : safe >> 32) | (behind & safe));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user