1 //===-- negti2_test.c - Test __negti2 -------------------------------------===//
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 __negti2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
21 ti_int
__negti2(ti_int a
);
23 int test__negti2(ti_int a
, ti_int expected
)
25 ti_int x
= __negti2(a
);
33 expectedt
.all
= expected
;
34 printf("error in __negti2: -0x%.16llX%.16llX = 0x%.16llX%.16llX, "
35 "expected 0x%.16llX%.16llX\n",
36 at
.s
.high
, at
.s
.low
, xt
.s
.high
, xt
.s
.low
, expectedt
.s
.high
, expectedt
.s
.low
);
41 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
48 if (test__negti2(0, 0))
50 if (test__negti2(1, -1))
52 if (test__negti2(-1, 1))
54 if (test__negti2(2, -2))
56 if (test__negti2(-2, 2))
58 if (test__negti2(3, -3))
60 if (test__negti2(-3, 3))
62 if (test__negti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
),
63 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
)))
65 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
),
66 make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
)))
68 if (test__negti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
),
69 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
)))
71 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
),
72 make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
)))
74 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
),
75 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
77 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
),
78 make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
80 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
),
81 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
83 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
),
84 make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
86 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000300000000LL
),
87 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
)))
89 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
),
90 make_ti(0x0000000000000000LL
, 0x0000000300000000LL
)))
92 if (test__negti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
),
93 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
95 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
),
96 make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
)))
98 if (test__negti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
),
99 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
101 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
),
102 make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
104 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
),
105 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
107 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
),
108 make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
110 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
),
111 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
113 if (test__negti2(make_ti(0x8000000000000000LL
, 0x0000000000000000LL
),
114 make_ti(0x8000000000000000LL
, 0x0000000000000000LL
)))
116 if (test__negti2(make_ti(0x8000000000000000LL
, 0x0000000000000001LL
),
117 make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
119 if (test__negti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
),
120 make_ti(0x8000000000000000LL
, 0x0000000000000001LL
)))