]> git.sesse.net Git - stockfish/commitdiff
Remove defined(IS_64BIT) in init_sliding_attacks()
authorMarco Costalba <mcostalba@gmail.com>
Sat, 29 Jan 2011 12:59:23 +0000 (13:59 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 29 Jan 2011 13:06:29 +0000 (14:06 +0100)
No functional change bith in 32 and 64 bits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp
src/bitcount.h
src/types.h

index dd12dd3ad509775276ebee5345836b9b194ce35b..bc8d5c3d93664f9b0a543d9e990817a86802728c 100644 (file)
@@ -451,27 +451,19 @@ namespace {
 
   void init_sliding_attacks(Bitboard attacks[], int attackIndex[], Bitboard mask[],
                             const int shift[], const Bitboard mult[], int deltas[][2]) {
 
   void init_sliding_attacks(Bitboard attacks[], int attackIndex[], Bitboard mask[],
                             const int shift[], const Bitboard mult[], int deltas[][2]) {
+    Bitboard b, v;
+    int i, j, index;
 
 
-    for (int i = 0, index = 0; i < 64; i++)
+    for (i = index = 0; i < 64; i++)
     {
         attackIndex[i] = index;
         mask[i] = sliding_attacks(i, 0, deltas, 1, 6, 1, 6);
     {
         attackIndex[i] = index;
         mask[i] = sliding_attacks(i, 0, deltas, 1, 6, 1, 6);
-
-#if defined(IS_64BIT)
-        int j = (1 << (64 - shift[i]));
-#else
-        int j = (1 << (32 - shift[i]));
-#endif
+        j = 1 << ((CpuIs64Bit ? 64 : 32) - shift[i]);
 
         for (int k = 0; k < j; k++)
         {
 
         for (int k = 0; k < j; k++)
         {
-            Bitboard b = index_to_bitboard(k, mask[i]);
-
-#if defined(IS_64BIT)
-            Bitboard v = b * mult[i];
-#else
-            unsigned v = int(b) * int(mult[i]) ^ int(b >> 32) * int(mult[i] >> 32);
-#endif
+            b = index_to_bitboard(k, mask[i]);
+            v = CpuIs64Bit ? b * mult[i] : unsigned(b * mult[i] ^ (b >> 32) * (mult[i] >> 32));
             attacks[index + (v >> shift[i])] = sliding_attacks(i, b, deltas, 0, 7, 0, 7);
         }
         index += j;
             attacks[index + (v >> shift[i])] = sliding_attacks(i, b, deltas, 0, 7, 0, 7);
         }
         index += j;
index 940dbaf52af207c8a24977e8780b42679e36650c..2e417e04fbf06474f43c8037b42d8cf9da0ba901 100644 (file)
@@ -96,32 +96,4 @@ inline int count_1s<CNT_POPCNT>(Bitboard b) {
 #endif
 }
 
 #endif
 }
 
-
-/// cpu_has_popcnt() detects support for popcnt instruction at runtime
-inline bool cpu_has_popcnt() {
-
-  int CPUInfo[4] = {-1};
-  __cpuid(CPUInfo, 0x00000001);
-  return (CPUInfo[2] >> 23) & 1;
-}
-
-
-/// CpuHasPOPCNT is a global constant initialized at startup that
-/// is set to true if CPU on which application runs supports popcnt
-/// hardware instruction. Unless USE_POPCNT is not defined.
-#if defined(USE_POPCNT)
-const bool CpuHasPOPCNT = cpu_has_popcnt();
-#else
-const bool CpuHasPOPCNT = false;
-#endif
-
-
-/// CpuIs64Bit is a global constant initialized at compile time that
-/// is set to true if CPU on which application runs is a 64 bits.
-#if defined(IS_64BIT)
-const bool CpuIs64Bit = true;
-#else
-const bool CpuIs64Bit = false;
-#endif
-
 #endif // !defined(BITCOUNT_H_INCLUDED)
 #endif // !defined(BITCOUNT_H_INCLUDED)
index 67e40fffd2c53ba54164c8910f99fd407cdd0a98..70b1b813c92af81edae6ff95123b18b8a54fa126 100644 (file)
@@ -146,4 +146,31 @@ inline void operator-= (T& d1, const T d2) { d1 = d1 - d2; } \
 inline void operator*= (T& d, int i) { d = T(int(d) * i); } \
 inline void operator/= (T& d, int i) { d = T(int(d) / i); }
 
 inline void operator*= (T& d, int i) { d = T(int(d) * i); } \
 inline void operator/= (T& d, int i) { d = T(int(d) / i); }
 
+
+/// cpu_has_popcnt() detects support for popcnt instruction at runtime
+inline bool cpu_has_popcnt() {
+
+  int CPUInfo[4] = {-1};
+  __cpuid(CPUInfo, 0x00000001);
+  return (CPUInfo[2] >> 23) & 1;
+}
+
+/// CpuHasPOPCNT is a global constant initialized at startup that
+/// is set to true if CPU on which application runs supports popcnt
+/// hardware instruction. Unless USE_POPCNT is not defined.
+#if defined(USE_POPCNT)
+const bool CpuHasPOPCNT = cpu_has_popcnt();
+#else
+const bool CpuHasPOPCNT = false;
+#endif
+
+
+/// CpuIs64Bit is a global constant initialized at compile time that
+/// is set to true if CPU on which application runs is a 64 bits.
+#if defined(IS_64BIT)
+const bool CpuIs64Bit = true;
+#else
+const bool CpuIs64Bit = false;
+#endif
+
 #endif // !defined(TYPES_H_INCLUDED)
 #endif // !defined(TYPES_H_INCLUDED)