1 //===-- ffsti2_test.c - Test __ffsti2 -------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __ffsti2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
19 // Returns: the index of the least significant 1-bit in a, or
20 // the value zero if a is zero. The least significant bit is index one.
22 si_int
__ffsti2(ti_int a
);
24 int test__ffsti2(ti_int a
, si_int expected
)
26 si_int x
= __ffsti2(a
);
31 printf("error in __ffsti2(0x%llX%.16llX) = %d, expected %d\n",
32 at
.s
.high
, at
.s
.low
, x
, expected
);
37 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
44 if (test__ffsti2(0x00000000, 0))
46 if (test__ffsti2(0x00000001, 1))
48 if (test__ffsti2(0x00000002, 2))
50 if (test__ffsti2(0x00000003, 1))
52 if (test__ffsti2(0x00000004, 3))
54 if (test__ffsti2(0x00000005, 1))
56 if (test__ffsti2(0x0000000A, 2))
58 if (test__ffsti2(0x10000000, 29))
60 if (test__ffsti2(0x20000000, 30))
62 if (test__ffsti2(0x60000000, 30))
64 if (test__ffsti2(0x80000000uLL
, 32))
66 if (test__ffsti2(0x0000050000000000uLL
, 41))
68 if (test__ffsti2(0x0200080000000000uLL
, 44))
70 if (test__ffsti2(0x7200000000000000uLL
, 58))
72 if (test__ffsti2(0x8000000000000000uLL
, 64))
74 if (test__ffsti2(make_ti(0x8000000800000000uLL
, 0), 100))
76 if (test__ffsti2(make_ti(0x8000000000000000uLL
, 0), 128))