1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Remove some pointless micro-optimizations

Seems to give around 1% speed-up for CPUs with popcnt support.
Seems to give a very minor speed-up for CPUs without popcnt.

No functional change

Resolves #646
This commit is contained in:
DU-jdto 2016-04-21 14:23:40 +10:00 committed by Joona Kiiski
parent 94e41274bb
commit c737062436
3 changed files with 9 additions and 21 deletions

View file

@ -234,7 +234,7 @@ namespace {
{
ei.kingRing[Them] = b | shift_bb<Down>(b);
b &= ei.attackedBy[Us][PAWN];
ei.kingAttackersCount[Us] = b ? popcount(b) : 0;
ei.kingAttackersCount[Us] = popcount(b);
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
}
else
@ -276,9 +276,7 @@ namespace {
{
ei.kingAttackersCount[Us]++;
ei.kingAttackersWeight[Us] += KingAttackWeights[Pt];
bb = b & ei.attackedBy[Them][KING];
if (bb)
ei.kingAdjacentZoneAttacksCount[Us] += popcount(bb);
ei.kingAdjacentZoneAttacksCount[Us] += popcount(b & ei.attackedBy[Them][KING]);
}
if (Pt == QUEEN)
@ -331,11 +329,7 @@ namespace {
{
// Bonus for aligning with enemy pawns on the same rank/file
if (relative_rank(Us, s) >= RANK_5)
{
Bitboard alignedPawns = pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s];
if (alignedPawns)
score += RookOnPawn * popcount(alignedPawns);
}
score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s]);
// Bonus when on an open or semi-open file
if (ei.pi->semiopen_file(Us, file_of(s)))
@ -417,7 +411,6 @@ namespace {
| ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]
| ei.attackedBy[Them][KING];
if (b)
attackUnits += QueenContactCheck * popcount(b);
}
@ -514,9 +507,7 @@ namespace {
while (b)
score += Threat[Rook ][type_of(pos.piece_on(pop_lsb(&b)))];
b = weak & ~ei.attackedBy[Them][ALL_PIECES];
if (b)
score += Hanging * popcount(b);
score += Hanging * popcount(weak & ~ei.attackedBy[Them][ALL_PIECES]);
b = weak & ei.attackedBy[Us][KING];
if (b)
@ -535,7 +526,6 @@ namespace {
& pos.pieces(Them)
& ~ei.attackedBy[Us][PAWN];
if (b)
score += ThreatByPawnPush * popcount(b);
if (DoTrace)

View file

@ -239,7 +239,7 @@ namespace {
&& !(PseudoAttacks[Pt][from] & target & ci->checkSquares[Pt]))
continue;
if (ci->dcCandidates && (ci->dcCandidates & from))
if (ci->dcCandidates & from)
continue;
}

View file

@ -501,8 +501,7 @@ bool Position::legal(Move m, Bitboard pinned) const {
// A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king.
return !pinned
|| !(pinned & from)
return !(pinned & from)
|| aligned(from, to_sq(m), square<KING>(us));
}
@ -595,8 +594,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
return true;
// Is there a discovered check?
if ( ci.dcCandidates
&& (ci.dcCandidates & from)
if ( (ci.dcCandidates & from)
&& !aligned(from, to, ci.ksq))
return true;