]> git.sesse.net Git - stockfish/commitdiff
Don't use _pext_u64() directly
authorMarco Costalba <mcostalba@gmail.com>
Tue, 20 Jan 2015 21:17:22 +0000 (22:17 +0100)
committerJoona Kiiski <joona.kiiski@gmail.com>
Sat, 24 Jan 2015 19:38:06 +0000 (19:38 +0000)
This intrinsic to call BMI2 PEXT instruction is
defined in immintrin.h. This header should be
included only when USE_PEXT is defined, otherwise
we define _pext_u64 as 0 forcing a nop.

But under some mingw platforms, even if we don't
include the header, immintrin.h gets included
anyhow through an include chain that starts with
STL <algorithm> header. So we end up both defining
_pext_u64 function and at the same time defining
_pext_u64 as 0 leading to a compile error.

The correct solution is of not using _pext_u64 directly.

This patch fixes a compile error with some mingw64
package when compiling with x86-64.

No functional change.

Resolves #222

src/bitboard.cpp
src/bitboard.h
src/types.h

index 4a0e275b960a8824b6d8596878a9b3b744aa22d8..32efaedafd55fcd92977babc906d493cb3bf9b85 100644 (file)
@@ -275,7 +275,7 @@ namespace {
             reference[size] = sliding_attack(deltas, s, b);
 
             if (HasPext)
-                attacks[s][_pext_u64(b, masks[s])] = reference[size];
+                attacks[s][pext(b, masks[s])] = reference[size];
 
             size++;
             b = (b - masks[s]) & masks[s];
index 38ddc6191cf31149820deafe07b68a5bf563f649..aa4e17119c1b5f7e81c56631641e8916c369d2d5 100644 (file)
@@ -238,7 +238,7 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occupied) {
   unsigned* const Shifts = Pt == ROOK ? RookShifts : BishopShifts;
 
   if (HasPext)
-      return unsigned(_pext_u64(occupied, Masks[s]));
+      return unsigned(pext(occupied, Masks[s]));
 
   if (Is64Bit)
       return unsigned(((occupied & Masks[s]) * Magics[s]) >> Shifts[s]);
index 2d7696307060002af557620d27c18b8087181cbd..7c5776ab3baaad266c790e90efc60bf4a7280152 100644 (file)
@@ -65,8 +65,9 @@
 
 #if defined(USE_PEXT)
 #  include <immintrin.h> // Header for _pext_u64() intrinsic
+#  define pext(b, m) _pext_u64(b, m)
 #else
-#  define _pext_u64(b, m) (0)
+#  define pext(b, m) (0)
 #endif
 
 #ifdef _MSC_VER