1 //===-- ffsdi2_test.c - Test __ffsdi2 -------------------------------------===//
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 __ffsdi2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
17 // Returns: the index of the least significant 1-bit in a, or
18 // the value zero if a is zero. The least significant bit is index one.
20 si_int
__ffsdi2(di_int a
);
22 int test__ffsdi2(di_int a
, si_int expected
)
24 si_int x
= __ffsdi2(a
);
26 printf("error in __ffsdi2(0x%llX) = %d, expected %d\n", a
, x
, expected
);
30 char assumption_1
[sizeof(di_int
) == 2*sizeof(si_int
)] = {0};
34 if (test__ffsdi2(0x00000000, 0))
36 if (test__ffsdi2(0x00000001, 1))
38 if (test__ffsdi2(0x00000002, 2))
40 if (test__ffsdi2(0x00000003, 1))
42 if (test__ffsdi2(0x00000004, 3))
44 if (test__ffsdi2(0x00000005, 1))
46 if (test__ffsdi2(0x0000000A, 2))
48 if (test__ffsdi2(0x10000000, 29))
50 if (test__ffsdi2(0x20000000, 30))
52 if (test__ffsdi2(0x60000000, 30))
54 if (test__ffsdi2(0x80000000uLL
, 32))
56 if (test__ffsdi2(0x0000050000000000uLL
, 41))
58 if (test__ffsdi2(0x0200080000000000uLL
, 44))
60 if (test__ffsdi2(0x7200000000000000uLL
, 58))
62 if (test__ffsdi2(0x8000000000000000uLL
, 64))