Fix avx512icl update_piece_threats bug

Thanks to MinetaS for discovering this and finding the culprit commit,
specific to this architecture. 9f42980 was subtly incorrect, leading to
spurious wrong benches on avx512icl. Because this piece of code has twice been
the source of wrong benches, I also added a brief comment explaining why it
needs to be this way, and added a sample position to bench.

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

Bench: 2288704
This commit is contained in:
anematode
2026-03-07 22:28:06 +01:00
committed by Joost VandeVondele
parent 2907ee1a90
commit b3a810a1c4
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -1131,7 +1131,9 @@ void Position::update_piece_threats(Piece pc,
if constexpr (PutPiece)
{
dts->threatenedSqs |= threatened;
dts->threateningSqs |= s;
// A bit may only be set if that square actually produces a threat, so we
// must guard setting the square accordingly
dts->threateningSqs |= Bitboard(bool(threatened)) << s;
}
DirtyThreat dt_template{pc, NO_PIECE, s, Square(0), PutPiece};
@@ -1142,7 +1144,7 @@ void Position::update_piece_threats(Piece pc,
if constexpr (PutPiece)
{
dts->threatenedSqs |= s;
dts->threatenedSqs |= Bitboard(bool(all_attackers)) << s; // same as above
dts->threateningSqs |= all_attackers;
}