summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-01-16 19:52:12 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-01-16 19:52:12 +0000
commit90a1773397c3ee3989b02f8d95a5fb6e9cb03885 (patch)
tree31fbbb2f0fd523b0ac8c432a35d56ee9ade683db
parentad228f4a72ed3a4e9556a588d1b9d789464fdacf (diff)
downloadbcm5719-llvm-90a1773397c3ee3989b02f8d95a5fb6e9cb03885.tar.gz
bcm5719-llvm-90a1773397c3ee3989b02f8d95a5fb6e9cb03885.zip
[Support] Add MSVC intrinsic for CountPopulation.
Patch by Jakub Staszak. llvm-svn: 172645
-rw-r--r--llvm/include/llvm/Support/MathExtras.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index 11f9e63c9bb..10911ea11c5 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/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);
OpenPOWER on IntegriCloud