[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / negvdi2_test.c
blob9e79dcbe69982b7897bbd6d097765870d29574db
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negvdi2
3 //===-- negvdi2_test.c - Test __negvdi2 -----------------------------------===//
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 __negvdi2 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 di_int __negvdi2(di_int a);
24 int test__negvdi2(di_int a)
26 di_int x = __negvdi2(a);
27 di_int expected = -a;
28 if (x != expected)
29 printf("error in __negvdi2(0x%llX) = %lld, expected %lld\n",
30 a, x, expected);
31 return x != expected;
34 int main()
36 // if (test__negvdi2(0x8000000000000000LL)) // should abort
37 // return 1;
38 if (test__negvdi2(0x0000000000000000LL))
39 return 1;
40 if (test__negvdi2(0x0000000000000001LL))
41 return 1;
42 if (test__negvdi2(0x0000000000000002LL))
43 return 1;
44 if (test__negvdi2(0x7FFFFFFFFFFFFFFELL))
45 return 1;
46 if (test__negvdi2(0x7FFFFFFFFFFFFFFFLL))
47 return 1;
48 if (test__negvdi2(0x8000000000000001LL))
49 return 1;
50 if (test__negvdi2(0x8000000000000002LL))
51 return 1;
52 if (test__negvdi2(0xFFFFFFFFFFFFFFFELL))
53 return 1;
54 if (test__negvdi2(0xFFFFFFFFFFFFFFFFLL))
55 return 1;
57 return 0;