mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Better annotate unlikely conditions
And in case of gcc we win also a small speed optimization due to better branch prediction. No functional change.
This commit is contained in:
parent
a6c5f60caa
commit
cbb1a8ed31
3 changed files with 10 additions and 2 deletions
|
@ -823,7 +823,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
|
||||||
// If there is an enemy rook or queen attacking the pawn from behind,
|
// If there is an enemy rook or queen attacking the pawn from behind,
|
||||||
// add all X-ray attacks by the rook or queen. Otherwise consider only
|
// add all X-ray attacks by the rook or queen. Otherwise consider only
|
||||||
// the squares in the pawn's path attacked or occupied by the enemy.
|
// the squares in the pawn's path attacked or occupied by the enemy.
|
||||||
if ( (forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN)) // Unlikely
|
if ( unlikely(forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN))
|
||||||
&& (forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN) & pos.attacks_from<ROOK>(s)))
|
&& (forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN) & pos.attacks_from<ROOK>(s)))
|
||||||
unsafeSquares = squaresToQueen;
|
unsafeSquares = squaresToQueen;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1454,7 +1454,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
| (attacks_bb<BISHOP>(m2to, occ) & pos.pieces(color_of(pc), QUEEN, BISHOP));
|
| (attacks_bb<BISHOP>(m2to, occ) & pos.pieces(color_of(pc), QUEEN, BISHOP));
|
||||||
|
|
||||||
// Verify attackers are triggered by our move and not already existing
|
// Verify attackers are triggered by our move and not already existing
|
||||||
if (xray && (xray & ~pos.attacks_from<QUEEN>(m2to))) // Unlikely xray
|
if (unlikely(xray) && (xray & ~pos.attacks_from<QUEEN>(m2to)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,14 @@
|
||||||
# define FORCE_INLINE inline
|
# define FORCE_INLINE inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
# define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
#else
|
||||||
|
# define likely(x) (x)
|
||||||
|
# define unlikely(x) (x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_POPCNT)
|
#if defined(USE_POPCNT)
|
||||||
const bool HasPopCnt = true;
|
const bool HasPopCnt = true;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue