1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_ctzti2
10 // Returns: the number of trailing 0-bits
12 // Precondition: a != 0
14 COMPILER_RT_ABI
int __ctzti2(ti_int a
);
16 int test__ctzti2(ti_int a
, int expected
)
23 printf("error in __ctzti2(0x%llX%.16llX) = %d, expected %d\n",
24 at
.s
.high
, at
.s
.low
, x
, expected
);
29 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
36 if (test__ctzti2(0x00000001, 0))
38 if (test__ctzti2(0x00000002, 1))
40 if (test__ctzti2(0x00000003, 0))
42 if (test__ctzti2(0x00000004, 2))
44 if (test__ctzti2(0x00000005, 0))
46 if (test__ctzti2(0x0000000A, 1))
48 if (test__ctzti2(0x10000000, 28))
50 if (test__ctzti2(0x20000000, 29))
52 if (test__ctzti2(0x60000000, 29))
54 if (test__ctzti2(0x80000000uLL
, 31))
56 if (test__ctzti2(0x0000050000000000uLL
, 40))
58 if (test__ctzti2(0x0200080000000000uLL
, 43))
60 if (test__ctzti2(0x7200000000000000uLL
, 57))
62 if (test__ctzti2(0x8000000000000000uLL
, 63))
64 if (test__ctzti2(make_ti(0x00000000A0000000LL
, 0x0000000000000000LL
), 93))
66 if (test__ctzti2(make_ti(0xF000000000000000LL
, 0x0000000000000000LL
), 124))
68 if (test__ctzti2(make_ti(0x8000000000000000LL
, 0x0000000000000000LL
), 127))