diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-01-16 19:52:12 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-01-16 19:52:12 +0000 |
commit | 2dcc27367ccc0ce03a78336472b9476d708d351e (patch) | |
tree | f20e6393280255ccf7f164eaa5ceb2681290844d /include | |
parent | 235c022296c2dc225bf3b4dfd5c8f8631222e570 (diff) | |
download | external_llvm-2dcc27367ccc0ce03a78336472b9476d708d351e.zip external_llvm-2dcc27367ccc0ce03a78336472b9476d708d351e.tar.gz external_llvm-2dcc27367ccc0ce03a78336472b9476d708d351e.tar.bz2 |
[Support] Add MSVC intrinsic for CountPopulation.
Patch by Jakub Staszak.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/MathExtras.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 11f9e63..10911ea 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -299,6 +299,8 @@ inline unsigned CountTrailingOnes_64(uint64_t Value) { inline unsigned CountPopulation_32(uint32_t Value) { #if __GNUC__ >= 4 return __builtin_popcount(Value); +#elif _MSC_VER + return __popcnt(Value); #else uint32_t v = Value - ((Value >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); @@ -311,6 +313,8 @@ inline unsigned CountPopulation_32(uint32_t Value) { inline unsigned CountPopulation_64(uint64_t Value) { #if __GNUC__ >= 4 return __builtin_popcountll(Value); +#elif _MSC_VER + return __popcnt64(Value); #else uint64_t v = Value - ((Value >> 1) & 0x5555555555555555ULL); v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL); |