mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Introduce least_significant_square_bb()
Introducing least_significant_square_bb(). It is a function that returns a value equal to square_bb(lsb(bb)), but it uses fewer instruction. It should speed up more on older processors like armv7-a Clang. Passed STC: LLR: 2.93 (-2.94,2.94) {-0.25,1.25} Total: 213200 W: 19171 L: 18753 D: 175276 Ptnml(0-2): 680, 14513, 75831, 14861, 715 https://tests.stockfishchess.org/tests/view/604bc7632433018de7a38982 Closes https://github.com/official-stockfish/Stockfish/pull/3391 No functional change
This commit is contained in:
parent
f3b296c2e2
commit
939395729c
2 changed files with 12 additions and 5 deletions
|
@ -414,6 +414,13 @@ inline Square msb(Bitboard b) {
|
|||
|
||||
#endif
|
||||
|
||||
/// least_significant_square_bb() returns the bitboard of the least significant
|
||||
/// square of a non-zero bitboard. It is equivalent to square_bb(lsb(bb)).
|
||||
|
||||
inline Bitboard least_significant_square_bb(Bitboard b) {
|
||||
assert(b);
|
||||
return b & -b;
|
||||
}
|
||||
|
||||
/// pop_lsb() finds and clears the least significant bit in a non-zero bitboard
|
||||
|
||||
|
|
|
@ -1109,7 +1109,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = PawnValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occupied ^= lsb(bb);
|
||||
occupied ^= least_significant_square_bb(bb);
|
||||
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
||||
}
|
||||
|
||||
|
@ -1118,7 +1118,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = KnightValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occupied ^= lsb(bb);
|
||||
occupied ^= least_significant_square_bb(bb);
|
||||
}
|
||||
|
||||
else if ((bb = stmAttackers & pieces(BISHOP)))
|
||||
|
@ -1126,7 +1126,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = BishopValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occupied ^= lsb(bb);
|
||||
occupied ^= least_significant_square_bb(bb);
|
||||
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = RookValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occupied ^= lsb(bb);
|
||||
occupied ^= least_significant_square_bb(bb);
|
||||
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1144,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = QueenValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occupied ^= lsb(bb);
|
||||
occupied ^= least_significant_square_bb(bb);
|
||||
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
|
||||
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue