20 #ifndef VC_COMMON_BITSCANINTRINSICS_H
21 #define VC_COMMON_BITSCANINTRINSICS_H
23 #if defined(VC_GCC) || defined(VC_CLANG)
24 # if VC_GCC >= 0x40500
26 # include <x86intrin.h>
29 # define _bit_scan_forward(x) __builtin_ctz(x)
33 __asm__(
"bsr %1,%0" :
"=r"(r) :
"X"(x));
36 #include "undomacros.h"
37 # define _bit_scan_reverse(x) _Vc_bit_scan_reverse_asm(x)
41 #elif defined(VC_OPEN64)
43 #elif defined(VC_MSVC)
45 #pragma intrinsic(_BitScanForward)
46 #pragma intrinsic(_BitScanReverse)
47 static inline __forceinline
unsigned long _bit_scan_forward(
unsigned long x) {
49 _BitScanForward(&index, x);
52 static inline __forceinline
unsigned long _bit_scan_reverse(
unsigned long x) {
54 _BitScanReverse(&index, x);
62 #endif // VC_COMMON_BITSCANINTRINSICS_H