1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_ffsti2
10 // Returns: the index of the least significant 1-bit in a, or
11 // the value zero if a is zero. The least significant bit is index one.
13 COMPILER_RT_ABI
int __ffsti2(ti_int a
);
15 int test__ffsti2(ti_int a
, int expected
)
22 printf("error in __ffsti2(0x%llX%.16llX) = %d, expected %d\n",
23 at
.s
.high
, at
.s
.low
, x
, expected
);
28 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
35 if (test__ffsti2(0x00000000, 0))
37 if (test__ffsti2(0x00000001, 1))
39 if (test__ffsti2(0x00000002, 2))
41 if (test__ffsti2(0x00000003, 1))
43 if (test__ffsti2(0x00000004, 3))
45 if (test__ffsti2(0x00000005, 1))
47 if (test__ffsti2(0x0000000A, 2))
49 if (test__ffsti2(0x10000000, 29))
51 if (test__ffsti2(0x20000000, 30))
53 if (test__ffsti2(0x60000000, 30))
55 if (test__ffsti2(0x80000000uLL
, 32))
57 if (test__ffsti2(0x0000050000000000uLL
, 41))
59 if (test__ffsti2(0x0200080000000000uLL
, 44))
61 if (test__ffsti2(0x7200000000000000uLL
, 58))
63 if (test__ffsti2(0x8000000000000000uLL
, 64))
65 if (test__ffsti2(make_ti(0x8000000800000000uLL
, 0), 100))
67 if (test__ffsti2(make_ti(0x8000000000000000uLL
, 0), 128))