X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.cpp;h=36d582d3a6a2ebec48639658a20241f6efb11786;hp=64cba6b5fc301322299a0eb3cf0d8c5102b07867;hb=76622342ec45a372b75bffdf81297861af78bbde;hpb=d6e3a40c819d29db00866bc7f09b9315dff9b95a diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 64cba6b5..36d582d3 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -58,6 +58,7 @@ namespace { CACHE_LINE_ALIGNMENT int BSFTable[64]; + int MS1BTable[256]; Bitboard RTable[0x19000]; // Storage space for rook attacks Bitboard BTable[0x1480]; // Storage space for bishop attacks @@ -160,7 +161,7 @@ Square last_1(Bitboard b) { result += 8; } - return Square(result + BitCount8Bit[b]); + return Square(result + MS1BTable[b]); } #endif // !defined(USE_BSFQ) @@ -170,6 +171,10 @@ Square last_1(Bitboard b) { void bitboards_init() { + for (int k = 0, i = 0; i < 8; i++) + while (k < (2 << i)) + MS1BTable[k++] = i; + for (Bitboard b = 0; b < 256; b++) BitCount8Bit[b] = (uint8_t)popcount(b);