@@ -439,6 +439,7 @@ namespace {
439439 template <Color Us, bool HasPopCnt>
440440 void init_eval_info (const Position& pos, EvalInfo& ei) {
441441
442+ const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
442443 const Color Them = (Us == WHITE ? BLACK : WHITE);
443444
444445 Bitboard b = ei.attackedBy [Them][KING] = pos.attacks_from <KING>(pos.king_square (Them));
@@ -448,7 +449,7 @@ namespace {
448449 if (ei.updateKingTables [Us])
449450 {
450451 b &= ei.attackedBy [Us][PAWN];
451- ei.kingAttackersCount [Us] = b ? count_1s_max_15<HasPopCnt >(b) / 2 : EmptyBoardBB;
452+ ei.kingAttackersCount [Us] = b ? count_1s<Max15 >(b) / 2 : EmptyBoardBB;
452453 ei.kingAdjacentZoneAttacksCount [Us] = ei.kingAttackersWeight [Us] = EmptyBoardBB;
453454 }
454455 }
@@ -491,6 +492,8 @@ namespace {
491492 File f;
492493 Score bonus = SCORE_ZERO;
493494
495+ const BitCountType Full = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64 : CNT32;
496+ const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
494497 const Color Them = (Us == WHITE ? BLACK : WHITE);
495498 const Square* ptr = pos.piece_list_begin (Us, Piece);
496499
@@ -518,12 +521,12 @@ namespace {
518521 ei.kingAttackersWeight [Us] += KingAttackWeights[Piece];
519522 Bitboard bb = (b & ei.attackedBy [Them][KING]);
520523 if (bb)
521- ei.kingAdjacentZoneAttacksCount [Us] += count_1s_max_15<HasPopCnt >(bb);
524+ ei.kingAdjacentZoneAttacksCount [Us] += count_1s<Max15 >(bb);
522525 }
523526
524527 // Mobility
525- mob = (Piece != QUEEN ? count_1s_max_15<HasPopCnt >(b & mobilityArea)
526- : count_1s<HasPopCnt >(b & mobilityArea));
528+ mob = (Piece != QUEEN ? count_1s<Max15 >(b & mobilityArea)
529+ : count_1s<Full >(b & mobilityArea));
527530
528531 mobility += MobilityBonus[Piece][mob];
529532
@@ -652,6 +655,7 @@ namespace {
652655 template <Color Us, bool HasPopCnt>
653656 Score evaluate_king (const Position& pos, EvalInfo& ei, Value& margin) {
654657
658+ const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
655659 const Color Them = (Us == WHITE ? BLACK : WHITE);
656660
657661 Bitboard undefended, b, b1, b2, safe;
@@ -680,7 +684,7 @@ namespace {
680684 // attacked and undefended squares around our king, the square of the
681685 // king, and the quality of the pawn shelter.
682686 attackUnits = Min (25 , (ei.kingAttackersCount [Them] * ei.kingAttackersWeight [Them]) / 2 )
683- + 3 * (ei.kingAdjacentZoneAttacksCount [Them] + count_1s_max_15<HasPopCnt >(undefended))
687+ + 3 * (ei.kingAdjacentZoneAttacksCount [Them] + count_1s<Max15 >(undefended))
684688 + InitKingDanger[relative_square (Us, ksq)]
685689 - mg_value (ei.pi ->king_shelter <Us>(pos, ksq)) / 32 ;
686690
@@ -694,7 +698,7 @@ namespace {
694698 | ei.attackedBy [Them][BISHOP] | ei.attackedBy [Them][ROOK]);
695699 if (b)
696700 attackUnits += QueenContactCheckBonus
697- * count_1s_max_15<HasPopCnt >(b)
701+ * count_1s<Max15 >(b)
698702 * (Them == pos.side_to_move () ? 2 : 1 );
699703 }
700704
@@ -712,7 +716,7 @@ namespace {
712716 | ei.attackedBy [Them][BISHOP] | ei.attackedBy [Them][QUEEN]);
713717 if (b)
714718 attackUnits += RookContactCheckBonus
715- * count_1s_max_15<HasPopCnt >(b)
719+ * count_1s<Max15 >(b)
716720 * (Them == pos.side_to_move () ? 2 : 1 );
717721 }
718722
@@ -725,22 +729,22 @@ namespace {
725729 // Enemy queen safe checks
726730 b = (b1 | b2) & ei.attackedBy [Them][QUEEN];
727731 if (b)
728- attackUnits += QueenCheckBonus * count_1s_max_15<HasPopCnt >(b);
732+ attackUnits += QueenCheckBonus * count_1s<Max15 >(b);
729733
730734 // Enemy rooks safe checks
731735 b = b1 & ei.attackedBy [Them][ROOK];
732736 if (b)
733- attackUnits += RookCheckBonus * count_1s_max_15<HasPopCnt >(b);
737+ attackUnits += RookCheckBonus * count_1s<Max15 >(b);
734738
735739 // Enemy bishops safe checks
736740 b = b2 & ei.attackedBy [Them][BISHOP];
737741 if (b)
738- attackUnits += BishopCheckBonus * count_1s_max_15<HasPopCnt >(b);
742+ attackUnits += BishopCheckBonus * count_1s<Max15 >(b);
739743
740744 // Enemy knights safe checks
741745 b = pos.attacks_from <KNIGHT>(ksq) & ei.attackedBy [Them][KNIGHT] & safe;
742746 if (b)
743- attackUnits += KnightCheckBonus * count_1s_max_15<HasPopCnt >(b);
747+ attackUnits += KnightCheckBonus * count_1s<Max15 >(b);
744748
745749 // To index KingDangerTable[] attackUnits must be in [0, 99] range
746750 attackUnits = Min (99 , Max (0 , attackUnits));
@@ -865,6 +869,7 @@ namespace {
865869 template <Color Us, bool HasPopCnt>
866870 int evaluate_space (const Position& pos, EvalInfo& ei) {
867871
872+ const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
868873 const Color Them = (Us == WHITE ? BLACK : WHITE);
869874
870875 // Find the safe squares for our pieces inside the area defined by
@@ -880,7 +885,7 @@ namespace {
880885 behind |= (Us == WHITE ? behind >> 8 : behind << 8 );
881886 behind |= (Us == WHITE ? behind >> 16 : behind << 16 );
882887
883- return count_1s_max_15<HasPopCnt >(safe) + count_1s_max_15<HasPopCnt >(behind & safe);
888+ return count_1s<Max15 >(safe) + count_1s<Max15 >(behind & safe);
884889 }
885890
886891
0 commit comments