1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_subvti3
13 // Effects: aborts if a - b overflows
15 COMPILER_RT_ABI ti_int
__subvti3(ti_int a
, ti_int b
);
17 int test__subvti3(ti_int a
, ti_int b
)
19 ti_int x
= __subvti3(a
, b
);
20 ti_int expected
= a
- b
;
30 expectedt
.all
= expected
;
31 printf("error in test__subvsi3(0x%.16llX%.16llX, 0x%.16llX%.16llX) = "
32 "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
33 at
.s
.high
, at
.s
.low
, bt
.s
.high
, bt
.s
.low
, xt
.s
.high
, xt
.s
.low
,
34 expectedt
.s
.high
, expectedt
.s
.low
);
44 // test__subvti3(make_ti(0x8000000000000000LL, 0), 1); // should abort
45 // test__subvti3(0, make_ti(0x8000000000000000LL, 0)); // should abort
46 // test__subvti3(1, make_ti(0x8000000000000000LL, 0)); // should abort
47 // test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), -1); // should abort
48 // test__subvti3(-2, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); // should abort
50 if (test__subvti3(make_ti(0x8000000000000000LL
, 0), -1))
52 if (test__subvti3(make_ti(0x8000000000000000LL
, 0), 0))
54 if (test__subvti3(-1, make_ti(0x8000000000000000LL
, 0)))
56 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
), 1))
58 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
), 0))
60 if (test__subvti3(1, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
62 if (test__subvti3(0, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
64 if (test__subvti3(-1, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))