[clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (#98138)
[llvm-project.git] / polly / lib / External / isl / isl_ffs.c
blobc1ee928f8b810343b5023ee36a98f0e51f2567fa
1 #include <isl_config.h>
3 #if !HAVE_DECL_FFS && !HAVE_DECL___BUILTIN_FFS && HAVE_DECL__BITSCANFORWARD
4 #include <intrin.h>
6 /* Implementation of ffs in terms of _BitScanForward.
8 * ffs returns the position of the least significant bit set in i,
9 * with the least significant bit is position 1, or 0 if not bits are set.
11 * _BitScanForward returns 1 if mask is non-zero and sets index
12 * to the position of the least significant bit set in i,
13 * with the least significant bit is position 0.
15 int isl_ffs(int i)
17 unsigned char non_zero;
18 unsigned long index, mask = i;
20 non_zero = _BitScanForward(&index, mask);
22 return non_zero ? 1 + index : 0;
24 #endif