1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negti2
4 //===-- negti2_test.c - Test __negti2 -------------------------------------===//
6 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7 // See https://llvm.org/LICENSE.txt for license information.
8 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 //===----------------------------------------------------------------------===//
12 // This file tests __negti2 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
23 COMPILER_RT_ABI ti_int
__negti2(ti_int a
);
25 int test__negti2(ti_int a
, ti_int expected
)
27 ti_int x
= __negti2(a
);
35 expectedt
.all
= expected
;
36 printf("error in __negti2: -0x%.16llX%.16llX = 0x%.16llX%.16llX, "
37 "expected 0x%.16llX%.16llX\n",
38 at
.s
.high
, at
.s
.low
, xt
.s
.high
, xt
.s
.low
, expectedt
.s
.high
, expectedt
.s
.low
);
43 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
50 if (test__negti2(0, 0))
52 if (test__negti2(1, -1))
54 if (test__negti2(-1, 1))
56 if (test__negti2(2, -2))
58 if (test__negti2(-2, 2))
60 if (test__negti2(3, -3))
62 if (test__negti2(-3, 3))
64 if (test__negti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
),
65 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
)))
67 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
),
68 make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
)))
70 if (test__negti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
),
71 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
)))
73 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
),
74 make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
)))
76 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
),
77 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
79 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
),
80 make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
82 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
),
83 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
85 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
),
86 make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
88 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000300000000LL
),
89 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
)))
91 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
),
92 make_ti(0x0000000000000000LL
, 0x0000000300000000LL
)))
94 if (test__negti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
),
95 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
97 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
),
98 make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
)))
100 if (test__negti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
),
101 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
103 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
),
104 make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
106 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
),
107 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
109 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
),
110 make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
112 if (test__negti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
),
113 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
115 if (test__negti2(make_ti(0x8000000000000000LL
, 0x0000000000000000LL
),
116 make_ti(0x8000000000000000LL
, 0x0000000000000000LL
)))
118 if (test__negti2(make_ti(0x8000000000000000LL
, 0x0000000000000001LL
),
119 make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
121 if (test__negti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
),
122 make_ti(0x8000000000000000LL
, 0x0000000000000001LL
)))