]> git.sesse.net Git - stockfish/commitdiff
Retire BitCount8Bit[] table
authorMarco Costalba <mcostalba@gmail.com>
Sat, 13 Oct 2012 12:21:27 +0000 (14:21 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 13 Oct 2012 12:24:01 +0000 (14:24 +0200)
Use popcount() instead in the only calling place.
It is used only at initialization so there is no
speed regression and anyhow even initialization
itself is not slowed down: magic bitboard setup
stays around 175 msec on my slow 32bit Core Duo.

No functional change.

src/bitboard.cpp

index 82608eab4f1ba1e937dc4dd56b29a73b5b2a6e20..26a668ae88cb3df006e9737d1cad70772cd8b243 100644 (file)
@@ -66,7 +66,6 @@ namespace {
   Square BSFTable[64];
   Bitboard RTable[0x19000]; // Storage space for rook attacks
   Bitboard BTable[0x1480];  // Storage space for bishop attacks
   Square BSFTable[64];
   Bitboard RTable[0x19000]; // Storage space for rook attacks
   Bitboard BTable[0x1480];  // Storage space for bishop attacks
-  uint8_t BitCount8Bit[256];
 
   typedef unsigned (Fn)(Square, Bitboard);
 
 
   typedef unsigned (Fn)(Square, Bitboard);
 
@@ -159,9 +158,6 @@ void Bitboards::init() {
   for (int i = 0; i < 64; i++)
       BSFTable[bsf_index(1ULL << i)] = Square(i);
 
   for (int i = 0; i < 64; i++)
       BSFTable[bsf_index(1ULL << i)] = Square(i);
 
-  for (Bitboard b = 0; b < 256; b++)
-      BitCount8Bit[b] = (uint8_t)popcount<Max15>(b);
-
   for (Square s = SQ_A1; s <= SQ_H8; s++)
       SquareBB[s] = 1ULL << s;
 
   for (Square s = SQ_A1; s <= SQ_H8; s++)
       SquareBB[s] = 1ULL << s;
 
@@ -324,7 +320,7 @@ namespace {
         // until we find the one that passes the verification test.
         do {
             do magics[s] = pick_random(rk, booster);
         // until we find the one that passes the verification test.
         do {
             do magics[s] = pick_random(rk, booster);
-            while (BitCount8Bit[(magics[s] * masks[s]) >> 56] < 6);
+            while (popcount<Max15>((magics[s] * masks[s]) >> 56) < 6);
 
             memset(attacks[s], 0, size * sizeof(Bitboard));
 
 
             memset(attacks[s], 0, size * sizeof(Bitboard));