29 #ifndef VC_COMMON_BITSCANINTRINSICS_H_
30 #define VC_COMMON_BITSCANINTRINSICS_H_
32 #if defined(Vc_GCC) || defined(Vc_CLANG)
33 # if Vc_GCC >= 0x40500
35 # include <x86intrin.h>
38 # define _bit_scan_forward(x) __builtin_ctz(x)
40 static Vc_ALWAYS_INLINE Vc_CONST
int _Vc_bit_scan_reverse_asm(
unsigned int x) {
42 __asm__(
"bsr %1,%0" :
"=r"(r) :
"X"(x));
45 # define _bit_scan_reverse(x) _Vc_bit_scan_reverse_asm(x)
49 #elif defined(Vc_OPEN64)
51 #elif defined(Vc_MSVC)
52 #include "windows_fix_intrin.h"
53 #pragma intrinsic(_BitScanForward)
54 #pragma intrinsic(_BitScanReverse)
55 static inline __forceinline
unsigned long _bit_scan_forward(
unsigned long x) {
57 _BitScanForward(&index, x);
60 static inline __forceinline
unsigned long _bit_scan_reverse(
unsigned long x) {
62 _BitScanReverse(&index, x);
70 #endif // VC_COMMON_BITSCANINTRINSICS_H_