mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Branchless correction history with to_sq_unchecked
Add Move::to_sq_unchecked() that bypasses the is_ok() assertion, for use in branchless code paths where invalid moves are masked out. passed STC: LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 92384 W: 24052 L: 23665 D: 44667 Ptnml(0-2): 265, 10229, 24831, 10588, 279 https://tests.stockfishchess.org/tests/view/6974dfc798dc5fff1dba5b74 closes https://github.com/official-stockfish/Stockfish/pull/6569 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
7f85cfbfa2
commit
542c30c292
+8
-7
@@ -114,13 +114,14 @@ void update_correction_history(const Position& pos,
|
||||
shared.nonpawn_correction_entry<WHITE>(pos).at(us).nonPawnWhite << bonus * nonPawnWeight / 128;
|
||||
shared.nonpawn_correction_entry<BLACK>(pos).at(us).nonPawnBlack << bonus * nonPawnWeight / 128;
|
||||
|
||||
if (m.is_ok())
|
||||
{
|
||||
const Square to = m.to_sq();
|
||||
const Piece pc = pos.piece_on(m.to_sq());
|
||||
(*(ss - 2)->continuationCorrectionHistory)[pc][to] << bonus * 127 / 128;
|
||||
(*(ss - 4)->continuationCorrectionHistory)[pc][to] << bonus * 59 / 128;
|
||||
}
|
||||
// Branchless: use mask to zero bonus when move is not ok
|
||||
const int mask = int(m.is_ok());
|
||||
const Square to = m.to_sq_unchecked();
|
||||
const Piece pc = pos.piece_on(to);
|
||||
const int bonus2 = (bonus * 127 / 128) * mask;
|
||||
const int bonus4 = (bonus * 59 / 128) * mask;
|
||||
(*(ss - 2)->continuationCorrectionHistory)[pc][to] << bonus2;
|
||||
(*(ss - 4)->continuationCorrectionHistory)[pc][to] << bonus4;
|
||||
}
|
||||
|
||||
// Add a small random component to draw evaluations to avoid 3-fold blindness
|
||||
|
||||
@@ -449,6 +449,10 @@ class Move {
|
||||
return Square(data & 0x3F);
|
||||
}
|
||||
|
||||
// Same as to_sq() but without assertion, for branchless code paths
|
||||
// where the result is masked/ignored when move is not ok
|
||||
constexpr Square to_sq_unchecked() const { return Square(data & 0x3F); }
|
||||
|
||||
constexpr MoveType type_of() const { return MoveType(data & (3 << 14)); }
|
||||
|
||||
constexpr PieceType promotion_type() const { return PieceType(((data >> 12) & 3) + KNIGHT); }
|
||||
|
||||
Reference in New Issue
Block a user