Skip to content

Commit

Permalink
Tentative speed up quiet moves validation
Browse files Browse the repository at this point in the history
Pre calculate killers from and to squares
so to quickly check the quiet move in 97%
of cases.

Indeed even if only in 3% of cases we fall
back on full validation, it seems original
code is still faster, even almost 2% !

No functional change.
  • Loading branch information
mcostalba committed Aug 24, 2014
1 parent 0794b1e commit bc7eb15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/movepick.cpp
Expand Up @@ -256,6 +256,15 @@ void MovePicker::generate_next_stage() {
score<QUIETS>();
end = std::partition(cur, end, has_positive_value);
insertion_sort(cur, end);

// Init killers bitboards to shortcut move's validity check later on
killersFrom = killersTo = 0;
if (ttMove != MOVE_NONE)
killersFrom |= from_sq(ttMove), killersTo |= to_sq(ttMove);

for (int i = 0; i < 6; i++)
if (killers[i].move != MOVE_NONE)
killersFrom |= from_sq(killers[i].move), killersTo |= to_sq(killers[i].move);
return;

case QUIETS_2_S1:
Expand Down Expand Up @@ -338,6 +347,9 @@ Move MovePicker::next_move<false>() {

case QUIETS_1_S1: case QUIETS_2_S1:
move = (cur++)->move;
if (!(killersTo & to_sq(move)) || !(killersFrom & from_sq(move)))
return move;

if ( move != ttMove
&& move != killers[0].move
&& move != killers[1].move
Expand Down
1 change: 1 addition & 0 deletions src/movepick.h
Expand Up @@ -102,6 +102,7 @@ class MovePicker {
Depth depth;
Move ttMove;
ExtMove killers[6];
Bitboard killersFrom, killersTo;
Square recaptureSquare;
Value captureThreshold;
int stage;
Expand Down

0 comments on commit bc7eb15

Please sign in to comment.