summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/distutils/checks/cpu_popcnt.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/numpy/distutils/checks/cpu_popcnt.c b/numpy/distutils/checks/cpu_popcnt.c
index e6a80fb40..540c98dab 100644
--- a/numpy/distutils/checks/cpu_popcnt.c
+++ b/numpy/distutils/checks/cpu_popcnt.c
@@ -4,20 +4,16 @@
#include <popcntintrin.h>
#endif
-int main(void)
+int main(int argc, char **argv)
{
- long long a = 0;
- int b;
-#ifdef _MSC_VER
- #ifdef _M_X64
- a = _mm_popcnt_u64(1);
- #endif
- b = _mm_popcnt_u32(1);
-#else
- #ifdef __x86_64__
- a = __builtin_popcountll(1);
- #endif
- b = __builtin_popcount(1);
+ // To make sure popcnt instructions are generated
+ // and been tested against the assembler
+ unsigned long long a = *((unsigned long long*)argv[argc-1]);
+ unsigned int b = *((unsigned int*)argv[argc-2]);
+
+#if defined(_M_X64) || defined(__x86_64__)
+ a = _mm_popcnt_u64(a);
#endif
+ b = _mm_popcnt_u32(b);
return (int)a + b;
}