diff --git a/numpy/distutils/checks/cpu_popcnt.c b/numpy/distutils/checks/cpu_popcnt.c index e6a80fb40be4..540c98dab05d 100644 --- a/numpy/distutils/checks/cpu_popcnt.c +++ b/numpy/distutils/checks/cpu_popcnt.c @@ -4,20 +4,16 @@ #include #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; }