1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_subvti3
4 //===-- subvti3_test.c - Test __subvti3 -----------------------------------===//
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 __subvti3 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
24 // Effects: aborts if a - b overflows
26 COMPILER_RT_ABI ti_int
__subvti3(ti_int a
, ti_int b
);
28 int test__subvti3(ti_int a
, ti_int b
)
30 ti_int x
= __subvti3(a
, b
);
31 ti_int expected
= a
- b
;
41 expectedt
.all
= expected
;
42 printf("error in test__subvsi3(0x%.16llX%.16llX, 0x%.16llX%.16llX) = "
43 "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
44 at
.s
.high
, at
.s
.low
, bt
.s
.high
, bt
.s
.low
, xt
.s
.high
, xt
.s
.low
,
45 expectedt
.s
.high
, expectedt
.s
.low
);
55 // test__subvti3(make_ti(0x8000000000000000LL, 0), 1); // should abort
56 // test__subvti3(0, make_ti(0x8000000000000000LL, 0)); // should abort
57 // test__subvti3(1, make_ti(0x8000000000000000LL, 0)); // should abort
58 // test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), -1); // should abort
59 // test__subvti3(-2, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); // should abort
61 if (test__subvti3(make_ti(0x8000000000000000LL
, 0), -1))
63 if (test__subvti3(make_ti(0x8000000000000000LL
, 0), 0))
65 if (test__subvti3(-1, make_ti(0x8000000000000000LL
, 0)))
67 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
), 1))
69 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
), 0))
71 if (test__subvti3(1, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
73 if (test__subvti3(0, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
75 if (test__subvti3(-1, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))