[Support] Include the intrisics header and check for definition properly.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 16 Jan 2013 20:50:43 +0000 (20:50 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 16 Jan 2013 20:50:43 +0000 (20:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172655 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/MathExtras.h

index 10911ea11c51ea96e8d4edf0a4b05e7b6a9c21f7..eaab8abe0764408e0015d92fd8c7d482a8b64a7f 100644 (file)
 
 #include "llvm/Support/SwapByteOrder.h"
 
+#ifdef _MSC_VER
+# include <intrin.h>
+#endif
+
 namespace llvm {
 
 // NOTE: The following support functions use the _32/_64 extensions instead of
@@ -299,7 +303,7 @@ inline unsigned CountTrailingOnes_64(uint64_t Value) {
 inline unsigned CountPopulation_32(uint32_t Value) {
 #if __GNUC__ >= 4
   return __builtin_popcount(Value);
-#elif _MSC_VER
+#elif defined(_MSC_VER)
   return __popcnt(Value);
 #else
   uint32_t v = Value - ((Value >> 1) & 0x55555555);
@@ -313,7 +317,7 @@ inline unsigned CountPopulation_32(uint32_t Value) {
 inline unsigned CountPopulation_64(uint64_t Value) {
 #if __GNUC__ >= 4
   return __builtin_popcountll(Value);
-#elif _MSC_VER
+#elif defined(_MSC_VER)
   return __popcnt64(Value);
 #else
   uint64_t v = Value - ((Value >> 1) & 0x5555555555555555ULL);