1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_addvti3
4 //===-- addvti3_test.c - Test __addvti3 -----------------------------------===//
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 __addvti3 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
23 // Effects: aborts if a + b overflows
25 COMPILER_RT_ABI ti_int
__addvti3(ti_int a
, ti_int b
);
27 int test__addvti3(ti_int a
, ti_int b
)
29 ti_int x
= __addvti3(a
, b
);
30 ti_int expected
= a
+ b
;
40 expectedt
.all
= expected
;
41 printf("error in test__addvti3(0x%llX%.16llX, 0x%llX%.16llX) = "
42 "0x%llX%.16llX, expected 0x%llX%.16llX\n",
43 at
.s
.high
, at
.s
.low
, bt
.s
.high
, bt
.s
.low
, xt
.s
.high
, xt
.s
.low
,
44 expectedt
.s
.high
, expectedt
.s
.low
);
55 // test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
56 // make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL));
58 // test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
59 // make_ti(0x8000000000000000LL, 0x0000000000000000LL));
61 // test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL),
62 // make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL));
64 // test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
65 // make_ti(0x0000000000000000LL, 0x0000000000000001LL));
67 if (test__addvti3(make_ti(0x8000000000000000LL
, 0x0000000000000000LL
),
68 make_ti(0x0000000000000000LL
, 0x0000000000000001LL
)))
70 if (test__addvti3(make_ti(0x0000000000000000LL
, 0x0000000000000001LL
),
71 make_ti(0x8000000000000000LL
, 0x0000000000000000LL
)))
73 if (test__addvti3(make_ti(0x8000000000000000LL
, 0x0000000000000000LL
),
74 make_ti(0x0000000000000000LL
, 0x0000000000000000LL
)))
76 if (test__addvti3(make_ti(0x0000000000000000LL
, 0x0000000000000000LL
),
77 make_ti(0x8000000000000000LL
, 0x0000000000000000LL
)))
79 if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
),
80 make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
82 if (test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
),
83 make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
85 if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
),
86 make_ti(0x0000000000000000LL
, 0x0000000000000000LL
)))
88 if (test__addvti3(make_ti(0x0000000000000000LL
, 0x0000000000000000LL
),
89 make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))