git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172655
91177308-0d34-0410-b5e6-
96231b3b80d8
#include "llvm/Support/SwapByteOrder.h"
#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
namespace llvm {
// NOTE: The following support functions use the _32/_64 extensions instead of
inline unsigned CountPopulation_32(uint32_t Value) {
#if __GNUC__ >= 4
return __builtin_popcount(Value);
inline unsigned CountPopulation_32(uint32_t Value) {
#if __GNUC__ >= 4
return __builtin_popcount(Value);
return __popcnt(Value);
#else
uint32_t v = Value - ((Value >> 1) & 0x55555555);
return __popcnt(Value);
#else
uint32_t v = Value - ((Value >> 1) & 0x55555555);
inline unsigned CountPopulation_64(uint64_t Value) {
#if __GNUC__ >= 4
return __builtin_popcountll(Value);
inline unsigned CountPopulation_64(uint64_t Value) {
#if __GNUC__ >= 4
return __builtin_popcountll(Value);
return __popcnt64(Value);
#else
uint64_t v = Value - ((Value >> 1) & 0x5555555555555555ULL);
return __popcnt64(Value);
#else
uint64_t v = Value - ((Value >> 1) & 0x5555555555555555ULL);