1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Don't use _pext_u64() directly

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
This commit is contained in:
Marco Costalba 2015-01-20 22:17:22 +01:00 committed by Joona Kiiski
parent 44643c2770
commit 54b5b528d9
3 changed files with 4 additions and 3 deletions

View file

@ -275,7 +275,7 @@ namespace {
reference[size] = sliding_attack(deltas, s, b); reference[size] = sliding_attack(deltas, s, b);
if (HasPext) if (HasPext)
attacks[s][_pext_u64(b, masks[s])] = reference[size]; attacks[s][pext(b, masks[s])] = reference[size];
size++; size++;
b = (b - masks[s]) & masks[s]; b = (b - masks[s]) & masks[s];

View file

@ -238,7 +238,7 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occupied) {
unsigned* const Shifts = Pt == ROOK ? RookShifts : BishopShifts; unsigned* const Shifts = Pt == ROOK ? RookShifts : BishopShifts;
if (HasPext) if (HasPext)
return unsigned(_pext_u64(occupied, Masks[s])); return unsigned(pext(occupied, Masks[s]));
if (Is64Bit) if (Is64Bit)
return unsigned(((occupied & Masks[s]) * Magics[s]) >> Shifts[s]); return unsigned(((occupied & Masks[s]) * Magics[s]) >> Shifts[s]);

View file

@ -65,8 +65,9 @@
#if defined(USE_PEXT) #if defined(USE_PEXT)
# include <immintrin.h> // Header for _pext_u64() intrinsic # include <immintrin.h> // Header for _pext_u64() intrinsic
# define pext(b, m) _pext_u64(b, m)
#else #else
# define _pext_u64(b, m) (0) # define pext(b, m) (0)
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER