Skip to content

Commit

Permalink
Merge pull request #19071 from cmichal2/main
Browse files Browse the repository at this point in the history
BUG: Fix compile-time test of POPCNT
  • Loading branch information
mattip committed May 23, 2021
2 parents 6e82773 + 3827c26 commit 3dcd924
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions numpy/distutils/checks/cpu_popcnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 3dcd924

Please sign in to comment.