Skip to content

Commit 38cfbee

Browse files
committed
Delay killers[] initialization
Most of the time we cut-off earlier, at captures, so this results in useless work. There is a small functionality change becuase 'ss' can change from MovePicker c'tor to when killers are tried due, for instance, to singular search. bench: 4603795
1 parent 77547a4 commit 38cfbee

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/movepick.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
7878
captureThreshold = 0;
7979
cur = end = moves;
8080
endBadCaptures = moves + MAX_MOVES - 1;
81+
countermoves = cm;
8182
ss = s;
8283

8384
if (p.checkers())
@@ -87,17 +88,12 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
8788
{
8889
phase = MAIN_SEARCH;
8990

90-
killers[0].move = ss->killers[0];
91-
killers[1].move = ss->killers[1];
92-
killers[2].move = cm[0];
93-
killers[3].move = cm[1];
94-
9591
// Consider sligtly negative captures as good if at low depth and far from beta
96-
if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
92+
if (ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
9793
captureThreshold = -PawnValueMg;
9894

9995
// Consider negative captures as good if still enough to reach beta
100-
else if (ss && ss->staticEval > beta)
96+
else if (ss->staticEval > beta)
10197
captureThreshold = beta - ss->staticEval;
10298
}
10399

@@ -241,15 +237,18 @@ void MovePicker::generate_next() {
241237
cur = killers;
242238
end = cur + 2;
243239

244-
if ((cur+3)->move && (cur+3)->move == (cur+2)->move) // Due to a SMP race
245-
(cur+3)->move = MOVE_NONE;
240+
killers[0].move = ss->killers[0];
241+
killers[1].move = ss->killers[1];
242+
killers[2].move = killers[3].move = MOVE_NONE;
246243

247244
// Be sure countermoves are different from killers
248-
if ((cur+2)->move != cur->move && (cur+2)->move != (cur+1)->move)
249-
end++;
245+
for (int i = 0; i < 2; i++)
246+
if (countermoves[i] != cur->move && countermoves[i] != (cur+1)->move)
247+
(end++)->move = countermoves[i];
248+
249+
if (countermoves[1] && countermoves[1] == countermoves[0]) // Due to SMP races
250+
killers[3].move = MOVE_NONE;
250251

251-
if ((cur+3)->move != cur->move && (cur+3)->move != (cur+1)->move)
252-
(end++)->move = (cur+3)->move;
253252
return;
254253

255254
case QUIETS_1_S1:

src/movepick.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class MovePicker {
9797
const Position& pos;
9898
const HistoryStats& history;
9999
Search::Stack* ss;
100+
Move* countermoves;
100101
Depth depth;
101102
Move ttMove;
102103
MoveStack killers[4];

0 commit comments

Comments
 (0)