diff options
author | Matti Picus <matti.picus@gmail.com> | 2021-05-23 21:27:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-23 21:27:00 +0300 |
commit | 3dcd9248d1f77cd2b0f97a5e9adb8e3cdcb3421f (patch) | |
tree | 904b22df4cbbb0b6a0e1de8812e38b79dfc23ff5 | |
parent | 6e82773ef1d171c7237f18bccf517409930daa05 (diff) | |
parent | 3827c262d128811f3ee36d2bd015544f5922e7c5 (diff) | |
download | numpy-3dcd9248d1f77cd2b0f97a5e9adb8e3cdcb3421f.tar.gz |
Merge pull request #19071 from cmichal2/main
BUG: Fix compile-time test of POPCNT
-rw-r--r-- | numpy/distutils/checks/cpu_popcnt.c | 22 |
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; } |