Skip to content

Commit 7614501

Browse files
committed
Fix POPCNT support for Intel compiler under Windows
Reported by Martin Wyngaarden that also confirmed this patch to work. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
1 parent 22ca7a6 commit 7614501

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/bitcount.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ template<>
8585
inline int count_1s<CNT_POPCNT>(Bitboard b) {
8686
#if !defined(USE_POPCNT)
8787
return int(b != 0); // Avoid 'b not used' warning
88+
#elif defined(_MSC_VER) && defined(__INTEL_COMPILER)
89+
return _mm_popcnt_u64(b);
8890
#elif defined(_MSC_VER)
8991
return __popcnt64(b);
9092
#elif defined(__GNUC__)

src/types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ typedef uint64_t Bitboard;
8686
#define USE_BSFQ
8787
#endif
8888

89+
// Intel header for _mm_popcnt_u64() intrinsic
90+
#if defined(USE_POPCNT) && defined(_MSC_VER) && defined(__INTEL_COMPILER)
91+
#include <nmmintrin.h>
92+
#endif
93+
8994
// Cache line alignment specification
9095
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
9196
#define CACHE_LINE_ALIGNMENT __declspec(align(64))

0 commit comments

Comments
 (0)