1 //===-- ctzdi2_test.c - Test __ctzdi2 -------------------------------------===//
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 __ctzdi2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
17 // Returns: the number of trailing 0-bits
19 // Precondition: a != 0
21 si_int
__ctzdi2(di_int a
);
23 int test__ctzdi2(di_int a
, si_int expected
)
25 si_int x
= __ctzdi2(a
);
27 printf("error in __ctzdi2(0x%llX) = %d, expected %d\n", a
, x
, expected
);
31 char assumption_1
[sizeof(di_int
) == 2*sizeof(si_int
)] = {0};
35 // if (test__ctzdi2(0x00000000, N)) // undefined
37 if (test__ctzdi2(0x00000001, 0))
39 if (test__ctzdi2(0x00000002, 1))
41 if (test__ctzdi2(0x00000003, 0))
43 if (test__ctzdi2(0x00000004, 2))
45 if (test__ctzdi2(0x00000005, 0))
47 if (test__ctzdi2(0x0000000A, 1))
49 if (test__ctzdi2(0x10000000, 28))
51 if (test__ctzdi2(0x20000000, 29))
53 if (test__ctzdi2(0x60000000, 29))
55 if (test__ctzdi2(0x80000000uLL
, 31))
57 if (test__ctzdi2(0x0000050000000000uLL
, 40))
59 if (test__ctzdi2(0x0200080000000000uLL
, 43))
61 if (test__ctzdi2(0x7200000000000000uLL
, 57))
63 if (test__ctzdi2(0x8000000000000000uLL
, 63))