mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
refactor update_piece_threats to reduce branching
Passed STC Non-Regression: https://tests.stockfishchess.org/tests/view/696f1a398b64097dacd231c3 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 122272 W: 31587 L: 31466 D: 59219 Ptnml(0-2): 301, 13358, 33750, 13373, 354 slight speedup as well: 1 thread bench: sf_base = 2238429 +/- 1221 (95%) sf_test = 2248298 +/- 1371 (95%) diff = 9869 +/- 1571 (95%) speedup = 0.44090% +/- 0.070% (95%) 32 thread speedtest: sf_base = 41016996 +/- 83654 (95%) sf_test = 41185801 +/- 84269 (95%) diff = 168805 +/- 79986 (95%) speedup = 0.41155% +/- 0.195% (95%) closes https://github.com/official-stockfish/Stockfish/pull/6559 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
9cc2985f51
commit
9f42980dd2
+11
-16
@@ -1069,8 +1069,8 @@ inline void add_dirty_threat(
|
|||||||
DirtyThreats* const dts, Piece pc, Piece threatened, Square s, Square threatenedSq) {
|
DirtyThreats* const dts, Piece pc, Piece threatened, Square s, Square threatenedSq) {
|
||||||
if (PutPiece)
|
if (PutPiece)
|
||||||
{
|
{
|
||||||
dts->threatenedSqs |= square_bb(threatenedSq);
|
dts->threatenedSqs |= threatenedSq;
|
||||||
dts->threateningSqs |= square_bb(s);
|
dts->threateningSqs |= s;
|
||||||
}
|
}
|
||||||
|
|
||||||
dts->list.push_back({pc, threatened, s, threatenedSq, PutPiece});
|
dts->list.push_back({pc, threatened, s, threatenedSq, PutPiece});
|
||||||
@@ -1139,30 +1139,25 @@ void Position::update_piece_threats(Piece pc,
|
|||||||
| (attacks_bb<PAWN>(s, BLACK) & whitePawns) | (PseudoAttacks[KING][s] & kings);
|
| (attacks_bb<PAWN>(s, BLACK) & whitePawns) | (PseudoAttacks[KING][s] & kings);
|
||||||
|
|
||||||
#ifdef USE_AVX512ICL
|
#ifdef USE_AVX512ICL
|
||||||
if (threatened)
|
if constexpr (PutPiece)
|
||||||
{
|
{
|
||||||
if constexpr (PutPiece)
|
dts->threatenedSqs |= threatened;
|
||||||
{
|
dts->threateningSqs |= s;
|
||||||
dts->threatenedSqs |= threatened;
|
|
||||||
dts->threateningSqs |= square_bb(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
DirtyThreat dt_template{pc, NO_PIECE, s, Square(0), PutPiece};
|
|
||||||
write_multiple_dirties<DirtyThreat::ThreatenedSqOffset, DirtyThreat::ThreatenedPcOffset>(
|
|
||||||
*this, threatened, dt_template, dts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DirtyThreat dt_template{pc, NO_PIECE, s, Square(0), PutPiece};
|
||||||
|
write_multiple_dirties<DirtyThreat::ThreatenedSqOffset, DirtyThreat::ThreatenedPcOffset>(
|
||||||
|
*this, threatened, dt_template, dts);
|
||||||
|
|
||||||
Bitboard all_attackers = sliders | incoming_threats;
|
Bitboard all_attackers = sliders | incoming_threats;
|
||||||
if (!all_attackers)
|
|
||||||
return; // Square s is threatened iff there's at least one attacker
|
|
||||||
|
|
||||||
if constexpr (PutPiece)
|
if constexpr (PutPiece)
|
||||||
{
|
{
|
||||||
dts->threatenedSqs |= square_bb(s);
|
dts->threatenedSqs |= s;
|
||||||
dts->threateningSqs |= all_attackers;
|
dts->threateningSqs |= all_attackers;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirtyThreat dt_template{NO_PIECE, pc, Square(0), s, PutPiece};
|
dt_template = {NO_PIECE, pc, Square(0), s, PutPiece};
|
||||||
write_multiple_dirties<DirtyThreat::PcSqOffset, DirtyThreat::PcOffset>(*this, all_attackers,
|
write_multiple_dirties<DirtyThreat::PcSqOffset, DirtyThreat::PcOffset>(*this, all_attackers,
|
||||||
dt_template, dts);
|
dt_template, dts);
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user