From 3bb01ce7a9f5bf60b4ce4e608b39f4a64a57e001 Mon Sep 17 00:00:00 2001 From: Timothy Herchen Date: Fri, 17 Oct 2025 23:39:45 -0700 Subject: [PATCH] prefetch earlier if checKEP is false Only a modest amount of work happens between the transposition table prefetch and the probe, so the probe still often stalls waiting for DRAM. The vast majority of the time (in particular, if !checkEP), the key is known much earlier in the do_move function and the latency can be better hidden. passed STC SMP https://tests.stockfishchess.org/tests/view/68f337c528e6d77fcffa066a LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 65256 W: 16806 L: 16462 D: 31988 Ptnml(0-2): 76, 7386, 17362, 7726, 78 but failed to gain STC https://tests.stockfishchess.org/tests/view/68f3378328e6d77fcffa0665 LLR: -2.94 (-2.94,2.94) <0.00,2.00> Total: 109824 W: 28523 L: 28618 D: 52683 Ptnml(0-2): 311, 11799, 30788, 11702, 312 In local tests, the speedup grows with thread count closes https://github.com/official-stockfish/Stockfish/pull/6372 No functional change --- src/position.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/position.cpp b/src/position.cpp index d0cad3e7f..1551eb9df 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -858,6 +858,10 @@ DirtyPiece Position::do_move(Move m, st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to]; } + // If en passant is impossible, then k will not change and we can prefetch earlier + if (tt && !checkEP) + prefetch(tt->first_entry(adjust_key50(k))); + // Set capture piece st->capturedPiece = captured;