1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Inline common path of pos.gives_check

Test for common case which, when running default
stockfish bench, avoids 96% of 19 million calls to
pos.gives_check().

Yields to a 2-4% speed up according to platform.

Passed fishtest at STC
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 12441 W: 2333 L: 2196 D: 7912
http://tests.stockfishchess.org/tests/view/52f02d790ebc5901df50f887

Passed fishtest at LTC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 42175 W: 6702 L: 6409 D: 29064
http://tests.stockfishchess.org/tests/view/52f0dbe00ebc5901df50f8a0

No functional change.
This commit is contained in:
Thanar2 2014-02-03 17:09:28 -05:00 committed by Marco Costalba
parent 0a1092f64e
commit d48a304262

View 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