]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/builtins/Unit/negti2_test.c
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 //===-- negti2_test.c - Test __negti2 -------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // This file tests __negti2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
22 COMPILER_RT_ABI ti_int
__negti2(ti_int a
);
24 int test__negti2(ti_int a
, ti_int expected
)
26 ti_int x
= __negti2(a
);
34 expectedt
.all
= expected
;
35 printf("error in __negti2: -0x%.16llX%.16llX = 0x%.16llX%.16llX, "
36 "expected 0x%.16llX%.16llX\n",
37 at
.s
.high
, at
.s
.low
, xt
.s
.high
, xt
.s
.low
, expectedt
.s
.high
, expectedt
.s
.low
);
42 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
49 if (test__negti2(0, 0))
51 if (test__negti2(1, -1))
53 if (test__negti2(-1, 1))
55 if (test__negti2(2, -2))
57 if (test__negti2(-2, 2))
59 if (test__negti2(3, -3))
61 if (test__negti2(-3, 3))
63 if (test__negti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
),
64 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
)))
66 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
),
67 make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
)))
69 if (test__negti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
),
70 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
)))
72 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
),
73 make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
)))
75 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
),
76 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
78 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
),
79 make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
81 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
),
82 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
84 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
),
85 make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
87 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000300000000LL
),
88 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
)))
90 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
),
91 make_ti(0x0000000000000000LL
, 0x0000000300000000LL
)))
93 if (test__negti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
),
94 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
96 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
),
97 make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
)))
99 if (test__negti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
),
100 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
102 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
),
103 make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
105 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
),
106 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
108 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
),
109 make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
111 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
),
112 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
114 if (test__negti2(make_ti(0x8000000000000000LL
, 0x0000000000000000LL
),
115 make_ti(0x8000000000000000LL
, 0x0000000000000000LL
)))
117 if (test__negti2(make_ti(0x8000000000000000LL
, 0x0000000000000001LL
),
118 make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
120 if (test__negti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
),
121 make_ti(0x8000000000000000LL
, 0x0000000000000001LL
)))