1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negdi2
9 COMPILER_RT_ABI di_int
__negdi2(di_int a
);
11 int test__negdi2(di_int a
, di_int expected
)
13 di_int x
= __negdi2(a
);
15 printf("error in __negdi2: -0x%llX = 0x%llX, expected 0x%llX\n",
20 char assumption_1
[sizeof(di_int
) == 2*sizeof(si_int
)] = {0};
24 if (test__negdi2(0, 0))
26 if (test__negdi2(1, -1))
28 if (test__negdi2(-1, 1))
30 if (test__negdi2(2, -2))
32 if (test__negdi2(-2, 2))
34 if (test__negdi2(3, -3))
36 if (test__negdi2(-3, 3))
38 if (test__negdi2(0x00000000FFFFFFFELL
, 0xFFFFFFFF00000002LL
))
40 if (test__negdi2(0xFFFFFFFF00000002LL
, 0x00000000FFFFFFFELL
))
42 if (test__negdi2(0x00000000FFFFFFFFLL
, 0xFFFFFFFF00000001LL
))
44 if (test__negdi2(0xFFFFFFFF00000001LL
, 0x00000000FFFFFFFFLL
))
46 if (test__negdi2(0x0000000100000000LL
, 0xFFFFFFFF00000000LL
))
48 if (test__negdi2(0xFFFFFFFF00000000LL
, 0x0000000100000000LL
))
50 if (test__negdi2(0x0000000200000000LL
, 0xFFFFFFFE00000000LL
))
52 if (test__negdi2(0xFFFFFFFE00000000LL
, 0x0000000200000000LL
))
54 if (test__negdi2(0x0000000300000000LL
, 0xFFFFFFFD00000000LL
))
56 if (test__negdi2(0xFFFFFFFD00000000LL
, 0x0000000300000000LL
))
58 if (test__negdi2(0x8000000000000000LL
, 0x8000000000000000LL
))
60 if (test__negdi2(0x8000000000000001LL
, 0x7FFFFFFFFFFFFFFFLL
))
62 if (test__negdi2(0x7FFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
))
64 if (test__negdi2(0xFFFFFFFE00000000LL
, 0x0000000200000000LL
))
66 if (test__negdi2(0x0000000200000000LL
, 0xFFFFFFFE00000000LL
))
68 if (test__negdi2(0xFFFFFFFF00000000LL
, 0x0000000100000000LL
))
70 if (test__negdi2(0x0000000100000000LL
, 0xFFFFFFFF00000000LL
))