X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.cpp;fp=src%2Fbitboard.cpp;h=f66d971b675987f720d305e5d009193dbabfae25;hp=d90201d3e10aebb5edb76fe295402ab9edff5fdd;hb=b8efa0daac897e1b8f3efb9ca09ec4151492f1e0;hpb=acc47e8b79058a06508fee804aa428820e163b8b diff --git a/src/bitboard.cpp b/src/bitboard.cpp index d90201d3..f66d971b 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -19,6 +19,7 @@ */ #include +#include #include "bitboard.h" #include "misc.h" @@ -49,14 +50,6 @@ namespace { Bitboard BishopTable[0x1480]; // To store bishop attacks void init_magics(Bitboard table[], Magic magics[], Direction directions[]); - - // popcount16() counts the non-zero bits using SWAR-Popcount algorithm - unsigned popcount16(unsigned u) { - u -= (u >> 1) & 0x5555U; - u = ((u >> 2) & 0x3333U) + (u & 0x3333U); - u = ((u >> 4) + u) & 0x0F0FU; - return (u * 0x0101U) >> 8; - } } @@ -85,7 +78,7 @@ const std::string Bitboards::pretty(Bitboard b) { void Bitboards::init() { for (unsigned i = 0; i < (1 << 16); ++i) - PopCnt16[i] = (uint8_t)popcount16(i); + PopCnt16[i] = std::bitset<16>(i).count(); for (Square s = SQ_A1; s <= SQ_H8; ++s) SquareBB[s] = (1ULL << s);