[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / addvsi3_test.c
blob73d9dbfb073d17dd50428e1082f4686da6336955
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_addvsi3
3 //===-- addvsi3_test.c - Test __addvsi3 -----------------------------------===//
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 __addvsi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 // Returns: a + b
20 // Effects: aborts if a + b overflows
22 COMPILER_RT_ABI si_int __addvsi3(si_int a, si_int b);
24 int test__addvsi3(si_int a, si_int b)
26 si_int x = __addvsi3(a, b);
27 si_int expected = a + b;
28 if (x != expected)
29 printf("error in test__addvsi3(0x%X, 0x%X) = %d, expected %d\n",
30 a, b, x, expected);
31 return x != expected;
34 int main()
36 // test__addvsi3(0x80000000, -1); // should abort
37 // test__addvsi3(-1, 0x80000000); // should abort
38 // test__addvsi3(1, 0x7FFFFFFF); // should abort
39 // test__addvsi3(0x7FFFFFFF, 1); // should abort
41 if (test__addvsi3(0x80000000, 1))
42 return 1;
43 if (test__addvsi3(1, 0x80000000))
44 return 1;
45 if (test__addvsi3(0x80000000, 0))
46 return 1;
47 if (test__addvsi3(0, 0x80000000))
48 return 1;
49 if (test__addvsi3(0x7FFFFFFF, -1))
50 return 1;
51 if (test__addvsi3(-1, 0x7FFFFFFF))
52 return 1;
53 if (test__addvsi3(0x7FFFFFFF, 0))
54 return 1;
55 if (test__addvsi3(0, 0x7FFFFFFF))
56 return 1;
58 return 0;