MCPcopy Create free account
hub / github.com/numpy/numpy / npyv__bitscan_revnz_u32

Function npyv__bitscan_revnz_u32

numpy/core/src/common/simd/intdiv.h:84–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 #include <intrin.h> // _BitScanReverse
83#endif
84NPY_FINLINE unsigned npyv__bitscan_revnz_u32(npy_uint32 a)
85{
86 assert(a > 0); // due to use __builtin_clz
87 unsigned r;
88#if defined(NPY_HAVE_SSE2) && defined(_MSC_VER)
89 unsigned long rl;
90 (void)_BitScanReverse(&rl, (unsigned long)a);
91 r = (unsigned)rl;
92
93#elif defined(NPY_HAVE_SSE2) && (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)) \
94 && (defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64))
95 __asm__("bsr %1, %0" : "=r" (r) : "r"(a));
96#elif defined(__GNUC__) || defined(__clang__)
97 r = 31 - __builtin_clz(a); // performs on arm -> clz, ppc -> cntlzw
98#else
99 r = 0;
100 while (a >>= 1) {
101 r++;
102 }
103#endif
104 return r;
105}
106NPY_FINLINE unsigned npyv__bitscan_revnz_u64(npy_uint64 a)
107{
108 assert(a > 0); // due to use __builtin_clzll

Callers 7

npyv__bitscan_revnz_u64Function · 0.85
npyv_divisor_u8Function · 0.85
npyv_divisor_s8Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected