1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-12 12:09:14 +00:00

Replace MS1BTable[] with BitCount8Bit[]

We already have the necessary infrastructure
in place.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2012-03-28 11:03:06 +02:00
parent cc2b3ece5c
commit 46a50cbf38
2 changed files with 19 additions and 20 deletions

View file

@ -58,7 +58,6 @@ namespace {
CACHE_LINE_ALIGNMENT CACHE_LINE_ALIGNMENT
int BSFTable[64]; int BSFTable[64];
int MS1BTable[256];
Bitboard RTable[0x19000]; // Storage space for rook attacks Bitboard RTable[0x19000]; // Storage space for rook attacks
Bitboard BTable[0x1480]; // Storage space for bishop attacks Bitboard BTable[0x1480]; // Storage space for bishop attacks
@ -139,25 +138,29 @@ Square pop_1st_bit(Bitboard* b) {
return Square(BSFTable[((~(u.b.h ^ (u.b.h - 1))) * 0x783A9B23) >> 26]); return Square(BSFTable[((~(u.b.h ^ (u.b.h - 1))) * 0x783A9B23) >> 26]);
} }
#endif // !defined(USE_BSFQ)
#if !defined(USE_BSFQ)
Square last_1(Bitboard b) { Square last_1(Bitboard b) {
int result = 0; int result = 0;
if (b > 0xFFFFFFFF) {
if (b > 0xFFFFFFFF)
{
b >>= 32; b >>= 32;
result = 32; result = 32;
} }
if (b > 0xFFFF) {
if (b > 0xFFFF)
{
b >>= 16; b >>= 16;
result += 16; result += 16;
} }
if (b > 0xFF) {
if (b > 0xFF)
{
b >>= 8; b >>= 8;
result += 8; result += 8;
} }
return Square(result + MS1BTable[b]);
return Square(result + BitCount8Bit[b]);
} }
#endif // !defined(USE_BSFQ) #endif // !defined(USE_BSFQ)
@ -217,11 +220,6 @@ void bitboards_init() {
else else
BSFTable[((1ULL << i) * 0x218A392CD3D5DBFULL) >> 58] = i; BSFTable[((1ULL << i) * 0x218A392CD3D5DBFULL) >> 58] = i;
MS1BTable[0] = 0;
for (int i = 0, k = 1; i < 8; i++)
for (int j = 0; j < (1 << i); j++)
MS1BTable[k++] = i;
int steps[][9] = { {}, { 7, 9 }, { 17, 15, 10, 6, -6, -10, -15, -17 }, int steps[][9] = { {}, { 7, 9 }, { 17, 15, 10, 6, -6, -10, -15, -17 },
{}, {}, {}, { 9, 7, -7, -9, 8, 1, -1, -8 } }; {}, {}, {}, { 9, 7, -7, -9, 8, 1, -1, -8 } };

View file

@ -214,6 +214,7 @@ inline bool single_bit(Bitboard b) {
return !(b & (b - 1)); return !(b & (b - 1));
} }
/// first_1() finds the least significant nonzero bit in a nonzero bitboard. /// first_1() finds the least significant nonzero bit in a nonzero bitboard.
/// pop_1st_bit() finds and clears the least significant nonzero bit in a /// pop_1st_bit() finds and clears the least significant nonzero bit in a
/// nonzero bitboard. /// nonzero bitboard.