Fix POPCNT support for Intel compiler under Windows
authorMarco Costalba <mcostalba@gmail.com>
Wed, 5 Jan 2011 10:02:05 +0000 (11:02 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 5 Jan 2011 20:12:19 +0000 (21:12 +0100)
Reported by Martin Wyngaarden that also confirmed
this patch to work.

No functional change.

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

index 0992c00..3c5ba2a 100644 (file)
@@ -85,6 +85,8 @@ template<>
 inline int count_1s<CNT_POPCNT>(Bitboard b) {
 #if !defined(USE_POPCNT)
   return int(b != 0); // Avoid 'b not used' warning
+#elif defined(_MSC_VER) && defined(__INTEL_COMPILER)
+  return _mm_popcnt_u64(b);
 #elif defined(_MSC_VER)
   return __popcnt64(b);
 #elif defined(__GNUC__)
index 161117f..a379d54 100644 (file)
@@ -86,6 +86,11 @@ typedef uint64_t Bitboard;
 #define USE_BSFQ
 #endif
 
+// Intel header for _mm_popcnt_u64() intrinsic
+#if defined(USE_POPCNT) && defined(_MSC_VER) && defined(__INTEL_COMPILER)
+#include <nmmintrin.h>
+#endif
+
 // Cache line alignment specification
 #if defined(_MSC_VER) || defined(__INTEL_COMPILER)
 #define CACHE_LINE_ALIGNMENT __declspec(align(64))