]> git.sesse.net Git - stockfish/commitdiff
Microptimize gives_check() for castling case
authorReuven Peleg <reuvenpe2005@gmail.com>
Fri, 19 Jul 2013 15:01:07 +0000 (17:01 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 19 Jul 2013 15:07:54 +0000 (17:07 +0200)
Without patch we have 333198 nps, with patch 334249.

A very small +0.3%, not a lot manily becuase this is a
side path that is taken very few times.

Anyhow idea is correct becuase first 'quick' condition
has an hit rate of about 95%.

No functional change.

src/position.cpp

index 1273a62fb3d0a0e975e2d06cdbf590359d9c473d..ad7ed3d915b7913e76a0f7a7e51ecce342f59356 100644 (file)
@@ -690,9 +690,9 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
       Square rfrom = to; // 'King captures the rook' notation
       Square kto = relative_square(us, rfrom > kfrom ? SQ_G1 : SQ_C1);
       Square rto = relative_square(us, rfrom > kfrom ? SQ_F1 : SQ_D1);
       Square rfrom = to; // 'King captures the rook' notation
       Square kto = relative_square(us, rfrom > kfrom ? SQ_G1 : SQ_C1);
       Square rto = relative_square(us, rfrom > kfrom ? SQ_F1 : SQ_D1);
-      Bitboard b = (pieces() ^ kfrom ^ rfrom) | rto | kto;
 
 
-      return attacks_bb<ROOK>(rto, b) & ksq;
+      return   (PseudoAttacks[ROOK][rto] & ksq)
+            && (attacks_bb<ROOK>(rto, (pieces() ^ kfrom ^ rfrom) | rto | kto) & ksq);
   }
   default:
       assert(false);
   }
   default:
       assert(false);