[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / negdi2_test.c
blob7f47d845ce5028a3bfa5e54d804a09972a49e555
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negdi2
3 //===-- negdi2_test.c - Test __negdi2 -------------------------------------===//
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 __negdi2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 // Returns: -a
20 COMPILER_RT_ABI di_int __negdi2(di_int a);
22 int test__negdi2(di_int a, di_int expected)
24 di_int x = __negdi2(a);
25 if (x != expected)
26 printf("error in __negdi2: -0x%llX = 0x%llX, expected 0x%llX\n",
27 a, x, expected);
28 return x != expected;
31 char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
33 int main()
35 if (test__negdi2(0, 0))
36 return 1;
37 if (test__negdi2(1, -1))
38 return 1;
39 if (test__negdi2(-1, 1))
40 return 1;
41 if (test__negdi2(2, -2))
42 return 1;
43 if (test__negdi2(-2, 2))
44 return 1;
45 if (test__negdi2(3, -3))
46 return 1;
47 if (test__negdi2(-3, 3))
48 return 1;
49 if (test__negdi2(0x00000000FFFFFFFELL, 0xFFFFFFFF00000002LL))
50 return 1;
51 if (test__negdi2(0xFFFFFFFF00000002LL, 0x00000000FFFFFFFELL))
52 return 1;
53 if (test__negdi2(0x00000000FFFFFFFFLL, 0xFFFFFFFF00000001LL))
54 return 1;
55 if (test__negdi2(0xFFFFFFFF00000001LL, 0x00000000FFFFFFFFLL))
56 return 1;
57 if (test__negdi2(0x0000000100000000LL, 0xFFFFFFFF00000000LL))
58 return 1;
59 if (test__negdi2(0xFFFFFFFF00000000LL, 0x0000000100000000LL))
60 return 1;
61 if (test__negdi2(0x0000000200000000LL, 0xFFFFFFFE00000000LL))
62 return 1;
63 if (test__negdi2(0xFFFFFFFE00000000LL, 0x0000000200000000LL))
64 return 1;
65 if (test__negdi2(0x0000000300000000LL, 0xFFFFFFFD00000000LL))
66 return 1;
67 if (test__negdi2(0xFFFFFFFD00000000LL, 0x0000000300000000LL))
68 return 1;
69 if (test__negdi2(0x8000000000000000LL, 0x8000000000000000LL))
70 return 1;
71 if (test__negdi2(0x8000000000000001LL, 0x7FFFFFFFFFFFFFFFLL))
72 return 1;
73 if (test__negdi2(0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL))
74 return 1;
75 if (test__negdi2(0xFFFFFFFE00000000LL, 0x0000000200000000LL))
76 return 1;
77 if (test__negdi2(0x0000000200000000LL, 0xFFFFFFFE00000000LL))
78 return 1;
79 if (test__negdi2(0xFFFFFFFF00000000LL, 0x0000000100000000LL))
80 return 1;
81 if (test__negdi2(0x0000000100000000LL, 0xFFFFFFFF00000000LL))
82 return 1;
84 return 0;