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