]> git.sesse.net Git - stockfish/commitdiff
Optimize an expression in endgame.cpp
authorprotonspring <mike@whiteley.org>
Mon, 11 Jun 2018 08:17:03 +0000 (10:17 +0200)
committerStéphane Nicolet <cassio@free.fr>
Mon, 11 Jun 2018 08:22:55 +0000 (10:22 +0200)
I believe using foward_file_bb() here is fewer instructions.

a) Fewer instructions and probably more clear (debatable).
b) Possible that a lookup is slower than a few local operations, but the
   forward_file_bb table is probably used often enough that it is always
   cached.

Passed
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 21004 W: 4263 L: 4141 D: 12600
http://tests.stockfishchess.org/tests/view/5b1cad830ebc5902ab9c6239

Closes https://github.com/official-stockfish/Stockfish/pull/1644

No functional change.

src/endgame.cpp

index db67ce95cf92923b012cfeb31b3ef28560f16771..3e01259c9745b01d90c0e9731f5bf2a6727fdf20 100644 (file)
@@ -214,7 +214,7 @@ Value Endgame<KRKP>::operator()(const Position& pos) const {
   Value result;
 
   // If the stronger side's king is in front of the pawn, it's a win
   Value result;
 
   // If the stronger side's king is in front of the pawn, it's a win
-  if (wksq < psq && file_of(wksq) == file_of(psq))
+  if (forward_file_bb(WHITE, wksq) & psq)
       result = RookValueEg - distance(wksq, psq);
 
   // If the weaker side's king is too far from the pawn and the rook,
       result = RookValueEg - distance(wksq, psq);
 
   // If the weaker side's king is too far from the pawn and the rook,