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
{
ei.kingRing[Them] = b | shift_bb<Down>(b);
b &= ei.attackedBy[Us][PAWN];
{
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
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
}
else
{
ei.kingAttackersCount[Us]++;
ei.kingAttackersWeight[Us] += KingAttackWeights[Pt];
{
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]);
{
// Bonus for aligning with enemy pawns on the same rank/file
if (relative_rank(Us, s) >= RANK_5)
{
// 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)))
// Bonus when on an open or semi-open file
if (ei.pi->semiopen_file(Us, file_of(s)))
| ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]
| ei.attackedBy[Them][KING];
| ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]
| ei.attackedBy[Them][KING];
- if (b)
- attackUnits += QueenContactCheck * popcount(b);
+ attackUnits += QueenContactCheck * popcount(b);
}
// Analyse the enemy's safe distance checks for sliders and knights
}
// Analyse the enemy's safe distance checks for sliders and knights
while (b)
score += Threat[Rook ][type_of(pos.piece_on(pop_lsb(&b)))];
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)
b = weak & ei.attackedBy[Us][KING];
if (b)
& pos.pieces(Them)
& ~ei.attackedBy[Us][PAWN];
& pos.pieces(Them)
& ~ei.attackedBy[Us][PAWN];
- if (b)
- score += ThreatByPawnPush * popcount(b);
+ score += ThreatByPawnPush * popcount(b);
if (DoTrace)
Trace::add(THREAT, Us, score);
if (DoTrace)
Trace::add(THREAT, Us, score);
&& !(PseudoAttacks[Pt][from] & target & ci->checkSquares[Pt]))
continue;
&& !(PseudoAttacks[Pt][from] & target & ci->checkSquares[Pt]))
continue;
- if (ci->dcCandidates && (ci->dcCandidates & from))
+ if (ci->dcCandidates & from)
// 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.
// 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));
}
|| aligned(from, to_sq(m), square<KING>(us));
}
return true;
// Is there a discovered check?
return true;
// Is there a discovered check?
- if ( ci.dcCandidates
- && (ci.dcCandidates & from)
+ if ( (ci.dcCandidates & from)
&& !aligned(from, to, ci.ksq))
return true;
&& !aligned(from, to, ci.ksq))
return true;