1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negvti2
4 //===-- negvti2_test.c - Test __negvti2 -----------------------------------===//
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 __negvti2 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
23 // Effects: aborts if -a overflows
25 COMPILER_RT_ABI ti_int
__negvti2(ti_int a
);
26 COMPILER_RT_ABI ti_int
__negti2(ti_int a
);
28 int test__negvti2(ti_int a
)
30 ti_int x
= __negvti2(a
);
31 ti_int expected
= __negti2(a
);
39 expectedt
.all
= expected
;
40 printf("error in __negvti2(0x%.16llX%.16llX) = 0x%.16llX%.16llX, "
41 "expected 0x%.16llX%.16llX\n",
42 at
.s
.high
, at
.s
.low
, xt
.s
.high
, xt
.s
.low
, expectedt
.s
.high
, expectedt
.s
.low
);
56 if (test__negvti2(-1))
60 if (test__negvti2(-2))
64 if (test__negvti2(-3))
66 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFELL
)))
68 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000002LL
)))
70 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x00000000FFFFFFFFLL
)))
72 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000001LL
)))
74 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
76 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
78 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
80 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
82 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x0000000300000000LL
)))
84 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFD00000000LL
)))
86 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
)))
88 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
)))
90 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x7FFFFFFFFFFFFFFFLL
)))
92 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFE00000000LL
)))
94 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x0000000200000000LL
)))
96 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFF00000000LL
)))
98 if (test__negvti2(make_ti(0x0000000000000000LL
, 0x0000000100000000LL
)))
100 // if (test__negvti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
102 if (test__negvti2(make_ti(0x8000000000000000LL
, 0x0000000000000001LL
)))
104 if (test__negvti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))