]> git.sesse.net Git - stockfish/commitdiff
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 0992c00625e084ecc1fa78110ccef0c04a500166..3c5ba2a1fa4004e40905e0b2514d76d4ab1518ee 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
 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__)
 #elif defined(_MSC_VER)
   return __popcnt64(b);
 #elif defined(__GNUC__)
index 161117f8536e433511824544c0ff8fbe8f653d7a..a379d5444956ef63537e4035eb27f1847faf70ca 100644 (file)
@@ -86,6 +86,11 @@ typedef uint64_t Bitboard;
 #define USE_BSFQ
 #endif
 
 #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))
 // Cache line alignment specification
 #if defined(_MSC_VER) || defined(__INTEL_COMPILER)
 #define CACHE_LINE_ALIGNMENT __declspec(align(64))