8000 Merge pull request #19074 from charris/backport-19071 · numpy/numpy@32b0261 · GitHub
[go: up one dir, main page]

Skip to content

Commit 32b0261

Browse files
authored
Merge pull request #19074 from charris/backport-19071
BUG: Fix compile-time test of POPCNT
2 parents 6d342f3 + 52d5fe1 commit 32b0261

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

numpy/distutils/checks/cpu_popcnt.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@
44
#include <popcntintrin.h>
55
#endif
66

7-
int main(void)
7+
int main(int argc, char **argv)
88
{
9-
long long a = 0;
10-
int b;
11-
#ifdef _MSC_VER
12-
#ifdef _M_X64
13-
a = _mm_popcnt_u64(1);
14-
#endif
15-
b = _mm_popcnt_u32(1);
16-
#else
17-
#ifdef __x86_64__
18-
a = __builtin_popcountll(1);
19-
#endif
20-
b = __builtin_popcount(1);
9+
// To make sure popcnt instructions are generated
10+
// and been tested against the assembler
11+
unsigned long long a = *((unsigned long long*)argv[argc-1]);
12+
unsigned int b = *((unsigned int*)argv[argc-2]);
13+
14+
#if defined(_M_X64) || defined(__x86_64__)
15+
a = _mm_popcnt_u64(a);
2116
#endif
17+
b = _mm_popcnt_u32(b);
2218
return (int)a + b;
2319
}

0 commit comments

Comments
 (0)
0