From af98814b97c1a85767d03fdf8ff509a3ff5a6777 Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Fri, 28 Jan 2022 14:26:13 +0000 Subject: [PATCH 1/2] Fixes #20930 Do not use __popcnt and variants for windows/arm64 target --- numpy/core/src/npymath/npy_math_internal.h.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/src/npymath/npy_math_internal.h.src b/numpy/core/src/npymath/npy_math_internal.h.src index 15d35637fb04..d43dcae9b64e 100644 --- a/numpy/core/src/npymath/npy_math_internal.h.src +++ b/numpy/core/src/npymath/npy_math_internal.h.src @@ -887,7 +887,7 @@ npy_popcountu@c@(npy_@type@ a) /* use built-in popcount if present, else use our implementation */ #if (defined(__clang__) || defined(__GNUC__)) && NPY_BITSOF_@STYPE@ >= 32 return __builtin_popcount@c@(a); -#elif defined(_MSC_VER) && NPY_BITSOF_@STYPE@ >= 16 +#elif defined(_MSC_VER) && NPY_BITSOF_@STYPE@ >= 16 && !defined(_M_ARM64) /* no builtin __popcnt64 for 32 bits */ #if defined(_WIN64) || (defined(_WIN32) && NPY_BITSOF_@STYPE@ != 64) return TO_BITS_LEN(__popcnt)(a); From e3afb6d372e1c0fafef2374e4d25f3717d68b3ad Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Fri, 28 Jan 2022 16:12:54 +0000 Subject: [PATCH 2/2] Extend fix for ARM32 --- numpy/core/src/npymath/npy_math_internal.h.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/src/npymath/npy_math_internal.h.src b/numpy/core/src/npymath/npy_math_internal.h.src index d43dcae9b64e..0364aabb1a9b 100644 --- a/numpy/core/src/npymath/npy_math_internal.h.src +++ b/numpy/core/src/npymath/npy_math_internal.h.src @@ -887,7 +887,7 @@ npy_popcountu@c@(npy_@type@ a) /* use built-in popcount if present, else use our implementation */ #if (defined(__clang__) || defined(__GNUC__)) && NPY_BITSOF_@STYPE@ >= 32 return __builtin_popcount@c@(a); -#elif defined(_MSC_VER) && NPY_BITSOF_@STYPE@ >= 16 && !defined(_M_ARM64) +#elif defined(_MSC_VER) && NPY_BITSOF_@STYPE@ >= 16 && !defined(_M_ARM64) && !defined(_M_ARM) /* no builtin __popcnt64 for 32 bits */ #if defined(_WIN64) || (defined(_WIN32) && NPY_BITSOF_@STYPE@ != 64) return TO_BITS_LEN(__popcnt)(a);