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
+/// 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
/// pop_lsb() finds and clears the least significant bit in a non-zero bitboard
if ((swap = PawnValueMg - swap) < res)
break;
if ((swap = PawnValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
if ((swap = KnightValueMg - swap) < res)
break;
if ((swap = KnightValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
}
else if ((bb = stmAttackers & pieces(BISHOP)))
}
else if ((bb = stmAttackers & pieces(BISHOP)))
if ((swap = BishopValueMg - swap) < res)
break;
if ((swap = BishopValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
if ((swap = RookValueMg - swap) < res)
break;
if ((swap = RookValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
}
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
}
if ((swap = QueenValueMg - swap) < res)
break;
if ((swap = QueenValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
}
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
}