1 //===-- negdi2_test.c - Test __negdi2 -------------------------------------===//
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 __negdi2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
19 di_int
__negdi2(di_int a
);
21 int test__negdi2(di_int a
, di_int expected
)
23 di_int x
= __negdi2(a
);
25 printf("error in __negdi2: -0x%llX = 0x%llX, expected 0x%llX\n",
30 char assumption_1
[sizeof(di_int
) == 2*sizeof(si_int
)] = {0};
34 if (test__negdi2(0, 0))
36 if (test__negdi2(1, -1))
38 if (test__negdi2(-1, 1))
40 if (test__negdi2(2, -2))
42 if (test__negdi2(-2, 2))
44 if (test__negdi2(3, -3))
46 if (test__negdi2(-3, 3))
48 if (test__negdi2(0x00000000FFFFFFFELL
, 0xFFFFFFFF00000002LL
))
50 if (test__negdi2(0xFFFFFFFF00000002LL
, 0x00000000FFFFFFFELL
))
52 if (test__negdi2(0x00000000FFFFFFFFLL
, 0xFFFFFFFF00000001LL
))
54 if (test__negdi2(0xFFFFFFFF00000001LL
, 0x00000000FFFFFFFFLL
))
56 if (test__negdi2(0x0000000100000000LL
, 0xFFFFFFFF00000000LL
))
58 if (test__negdi2(0xFFFFFFFF00000000LL
, 0x0000000100000000LL
))
60 if (test__negdi2(0x0000000200000000LL
, 0xFFFFFFFE00000000LL
))
62 if (test__negdi2(0xFFFFFFFE00000000LL
, 0x0000000200000000LL
))
64 if (test__negdi2(0x0000000300000000LL
, 0xFFFFFFFD00000000LL
))
66 if (test__negdi2(0xFFFFFFFD00000000LL
, 0x0000000300000000LL
))
68 if (test__negdi2(0x8000000000000000LL
, 0x8000000000000000LL
))
70 if (test__negdi2(0x8000000000000001LL
, 0x7FFFFFFFFFFFFFFFLL
))
72 if (test__negdi2(0x7FFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
))
74 if (test__negdi2(0xFFFFFFFE00000000LL
, 0x0000000200000000LL
))
76 if (test__negdi2(0x0000000200000000LL
, 0xFFFFFFFE00000000LL
))
78 if (test__negdi2(0xFFFFFFFF00000000LL
, 0x0000000100000000LL
))
80 if (test__negdi2(0x0000000100000000LL
, 0xFFFFFFFF00000000LL
))