]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Inline common path of pos.gives_check
[stockfish] / src / search.cpp
index 6d900f7bb7ae673575f2d52b953ed63ca2c2d3ff..95f1332ed1ddb6e1ca743e006cdf1039bcd034d8 100644 (file)
@@ -51,6 +51,12 @@ using std::string;
 using Eval::evaluate;
 using namespace Search;
 
+// Fast wrapper for common case of pos.gives_check()
+#define FAST_GIVES_CHECK(pos, m, ci) \
+    ((type_of(m) == NORMAL && ci.dcCandidates == 0) \
+       ? (ci.checkSq[type_of(pos.piece_on(from_sq(m)))] & to_sq(m)) \
+          : pos.gives_check(m, ci))
+
 namespace {
 
   // Set to true to force running with one thread. Used for debugging
@@ -754,7 +760,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
       ext = DEPTH_ZERO;
       captureOrPromotion = pos.capture_or_promotion(move);
-      givesCheck = pos.gives_check(move, ci);
+      givesCheck = FAST_GIVES_CHECK(pos, move, ci);
       dangerous =   givesCheck
                  || type_of(move) != NORMAL
                  || pos.advanced_pawn_push(move);
@@ -1134,7 +1140,7 @@ moves_loop: // When in check and at SpNode search starts from here
     {
       assert(is_ok(move));
 
-      givesCheck = pos.gives_check(move, ci);
+      givesCheck = FAST_GIVES_CHECK(pos, move, ci);
 
       // Futility pruning
       if (   !PvNode