[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / subvdi3_test.c
blob768428f67d21cec92bfe71bb617294bc204077d7
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_subvdi3
3 //===-- subvdi3_test.c - Test __subvdi3 -----------------------------------===//
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
11 // This file tests __subvdi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
17 #include <stdlib.h>
19 // Returns: a - b
21 // Effects: aborts if a - b overflows
23 COMPILER_RT_ABI di_int __subvdi3(di_int a, di_int b);
25 int test__subvdi3(di_int a, di_int b)
27 di_int x = __subvdi3(a, b);
28 di_int expected = a - b;
29 if (x != expected)
30 printf("error in test__subvsi3(0x%llX, 0x%llX) = %lld, expected %lld\n",
31 a, b, x, expected);
32 return x != expected;
35 int main()
37 // test__subvdi3(0x8000000000000000LL, 1); // should abort
38 // test__subvdi3(0, 0x8000000000000000LL); // should abort
39 // test__subvdi3(1, 0x8000000000000000LL); // should abort
40 // test__subvdi3(0x7FFFFFFFFFFFFFFFLL, -1); // should abort
41 // test__subvdi3(-2, 0x7FFFFFFFFFFFFFFFLL); // should abort
43 if (test__subvdi3(0x8000000000000000LL, -1))
44 return 1;
45 if (test__subvdi3(0x8000000000000000LL, 0))
46 return 1;
47 if (test__subvdi3(-1, 0x8000000000000000LL))
48 return 1;
49 if (test__subvdi3(0x7FFFFFFFFFFFFFFLL, 1))
50 return 1;
51 if (test__subvdi3(0x7FFFFFFFFFFFFFFFLL, 0))
52 return 1;
53 if (test__subvdi3(1, 0x7FFFFFFFFFFFFFFLL))
54 return 1;
55 if (test__subvdi3(0, 0x7FFFFFFFFFFFFFFFLL))
56 return 1;
57 if (test__subvdi3(-1, 0x7FFFFFFFFFFFFFFFLL))
58 return 1;
60 return 0;