Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / subvdi3_test.c
blobc4cff53e5139bf56f6a58589dc16d6ca138ee580
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_subvdi3
4 #include "int_lib.h"
5 #include <stdio.h>
6 #include <stdlib.h>
8 // Returns: a - b
10 // Effects: aborts if a - b overflows
12 COMPILER_RT_ABI di_int __subvdi3(di_int a, di_int b);
14 int test__subvdi3(di_int a, di_int b)
16 di_int x = __subvdi3(a, b);
17 di_int expected = a - b;
18 if (x != expected)
19 printf("error in test__subvsi3(0x%llX, 0x%llX) = %lld, expected %lld\n",
20 a, b, x, expected);
21 return x != expected;
24 int main()
26 // test__subvdi3(0x8000000000000000LL, 1); // should abort
27 // test__subvdi3(0, 0x8000000000000000LL); // should abort
28 // test__subvdi3(1, 0x8000000000000000LL); // should abort
29 // test__subvdi3(0x7FFFFFFFFFFFFFFFLL, -1); // should abort
30 // test__subvdi3(-2, 0x7FFFFFFFFFFFFFFFLL); // should abort
32 if (test__subvdi3(0x8000000000000000LL, -1))
33 return 1;
34 if (test__subvdi3(0x8000000000000000LL, 0))
35 return 1;
36 if (test__subvdi3(-1, 0x8000000000000000LL))
37 return 1;
38 if (test__subvdi3(0x7FFFFFFFFFFFFFFLL, 1))
39 return 1;
40 if (test__subvdi3(0x7FFFFFFFFFFFFFFFLL, 0))
41 return 1;
42 if (test__subvdi3(1, 0x7FFFFFFFFFFFFFFLL))
43 return 1;
44 if (test__subvdi3(0, 0x7FFFFFFFFFFFFFFFLL))
45 return 1;
46 if (test__subvdi3(-1, 0x7FFFFFFFFFFFFFFFLL))
47 return 1;
49 return 0;