mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Streamline generate_moves()
Greatly simplify these very performace critical functions. Amazingly we don't have any speed regression actually under MSVC we have the same assembly for generate_moves() ! In generate_direct_checks() 'target' is calculated only once being a loop invariant. On Clang there is even a slight speed up. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
b84af67f4c
commit
0de9257610
1 changed files with 16 additions and 25 deletions
|
@ -216,20 +216,15 @@ namespace {
|
||||||
|
|
||||||
|
|
||||||
template<PieceType Pt>
|
template<PieceType Pt>
|
||||||
inline MoveStack* generate_direct_checks(const Position& pos, MoveStack* mlist,
|
FORCE_INLINE MoveStack* generate_direct_checks(const Position& pos, MoveStack* mlist,
|
||||||
Color us, const CheckInfo& ci) {
|
Color us, const CheckInfo& ci) {
|
||||||
assert(Pt != KING && Pt != PAWN);
|
assert(Pt != KING && Pt != PAWN);
|
||||||
|
|
||||||
Bitboard b, target;
|
|
||||||
Square from;
|
|
||||||
const Square* pl = pos.piece_list(us, Pt);
|
const Square* pl = pos.piece_list(us, Pt);
|
||||||
|
|
||||||
if (*pl != SQ_NONE)
|
for (Square from = *pl; from != SQ_NONE; from = *++pl)
|
||||||
{
|
{
|
||||||
target = ci.checkSq[Pt] & ~pos.pieces(); // Non capture checks only
|
Bitboard target = ci.checkSq[Pt] & ~pos.pieces(); // Non capture checks only
|
||||||
|
|
||||||
do {
|
|
||||||
from = *pl;
|
|
||||||
|
|
||||||
if ( (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
|
if ( (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
|
||||||
&& !(PseudoAttacks[Pt][from] & target))
|
&& !(PseudoAttacks[Pt][from] & target))
|
||||||
|
@ -238,9 +233,8 @@ namespace {
|
||||||
if (ci.dcCandidates && (ci.dcCandidates & from))
|
if (ci.dcCandidates && (ci.dcCandidates & from))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
b = pos.attacks_from<Pt>(from) & target;
|
Bitboard b = pos.attacks_from<Pt>(from) & target;
|
||||||
SERIALIZE(b);
|
SERIALIZE(b);
|
||||||
} while (*++pl != SQ_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mlist;
|
return mlist;
|
||||||
|
@ -252,16 +246,13 @@ namespace {
|
||||||
Color us, Bitboard target) {
|
Color us, Bitboard target) {
|
||||||
assert(Pt != KING && Pt != PAWN);
|
assert(Pt != KING && Pt != PAWN);
|
||||||
|
|
||||||
Bitboard b;
|
|
||||||
Square from;
|
|
||||||
const Square* pl = pos.piece_list(us, Pt);
|
const Square* pl = pos.piece_list(us, Pt);
|
||||||
|
|
||||||
if (*pl != SQ_NONE)
|
for (Square from = *pl; from != SQ_NONE; from = *++pl)
|
||||||
do {
|
{
|
||||||
from = *pl;
|
Bitboard b = pos.attacks_from<Pt>(from) & target;
|
||||||
b = pos.attacks_from<Pt>(from) & target;
|
|
||||||
SERIALIZE(b);
|
SERIALIZE(b);
|
||||||
} while (*++pl != SQ_NONE);
|
}
|
||||||
|
|
||||||
return mlist;
|
return mlist;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue