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

Function npyv__bitscan_revnz_u64

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

Source from the content-addressed store, hash-verified

104 return r;
105}
106NPY_FINLINE unsigned npyv__bitscan_revnz_u64(npy_uint64 a)
107{
108 assert(a > 0); // due to use __builtin_clzll
109#if defined(_M_AMD64) && defined(_MSC_VER)
110 unsigned long rl;
111 (void)_BitScanReverse64(&rl, a);
112 return (unsigned)rl;
113#elif defined(__x86_64__) && (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER))
114 npy_uint64 r;
115 __asm__("bsrq %1, %0" : "=r"(r) : "r"(a));
116 return (unsigned)r;
117#elif defined(__GNUC__) || defined(__clang__)
118 return 63 - __builtin_clzll(a);
119#else
120 npy_uint64 a_hi = a >> 32;
121 if (a_hi == 0) {
122 return npyv__bitscan_revnz_u32((npy_uint32)a);
123 }
124 return 32 + npyv__bitscan_revnz_u32((npy_uint32)a_hi);
125#endif
126}
127/**
128 * Divides 128-bit unsigned integer by a 64-bit when the lower
129 * 64-bit of the dividend is zero.

Callers 3

Calls 1

npyv__bitscan_revnz_u32Function · 0.85

Tested by

no test coverage detected