1 //===-- subvti3_test.c - Test __subvti3 -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __subvti3 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
22 // Effects: aborts if a - b overflows
24 ti_int
__subvti3(ti_int a
, ti_int b
);
26 int test__subvti3(ti_int a
, ti_int b
)
28 ti_int x
= __subvti3(a
, b
);
29 ti_int expected
= a
- b
;
39 expectedt
.all
= expected
;
40 printf("error in test__subvsi3(0x%.16llX%.16llX, 0x%.16llX%.16llX) = "
41 "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
42 at
.s
.high
, at
.s
.low
, bt
.s
.high
, bt
.s
.low
, xt
.s
.high
, xt
.s
.low
,
43 expectedt
.s
.high
, expectedt
.s
.low
);
53 // test__subvti3(make_ti(0x8000000000000000LL, 0), 1); // should abort
54 // test__subvti3(0, make_ti(0x8000000000000000LL, 0)); // should abort
55 // test__subvti3(1, make_ti(0x8000000000000000LL, 0)); // should abort
56 // test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), -1); // should abort
57 // test__subvti3(-2, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); // should abort
59 if (test__subvti3(make_ti(0x8000000000000000LL
, 0), -1))
61 if (test__subvti3(make_ti(0x8000000000000000LL
, 0), 0))
63 if (test__subvti3(-1, make_ti(0x8000000000000000LL
, 0)))
65 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
), 1))
67 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
), 0))
69 if (test__subvti3(1, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
71 if (test__subvti3(0, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
73 if (test__subvti3(-1, make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))