[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / mulvdi3_test.c
blob81bd4b2a914b857ed52a65664a9eb5e1d197b172
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_mulvdi3
3 //===-- mulvdi3_test.c - Test __mulvdi3 -----------------------------------===//
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 __mulvdi3 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 di_int __mulvdi3(di_int a, di_int b);
24 int test__mulvdi3(di_int a, di_int b, di_int expected)
26 di_int x = __mulvdi3(a, b);
27 if (x != expected)
28 printf("error in __mulvdi3: %lld * %lld = %lld, expected %lld\n",
29 a, b, x, expected);
30 return x != expected;
33 int main()
35 if (test__mulvdi3(0, 0, 0))
36 return 1;
37 if (test__mulvdi3(0, 1, 0))
38 return 1;
39 if (test__mulvdi3(1, 0, 0))
40 return 1;
41 if (test__mulvdi3(0, 10, 0))
42 return 1;
43 if (test__mulvdi3(10, 0, 0))
44 return 1;
45 if (test__mulvdi3(0, 81985529216486895LL, 0))
46 return 1;
47 if (test__mulvdi3(81985529216486895LL, 0, 0))
48 return 1;
50 if (test__mulvdi3(0, -1, 0))
51 return 1;
52 if (test__mulvdi3(-1, 0, 0))
53 return 1;
54 if (test__mulvdi3(0, -10, 0))
55 return 1;
56 if (test__mulvdi3(-10, 0, 0))
57 return 1;
58 if (test__mulvdi3(0, -81985529216486895LL, 0))
59 return 1;
60 if (test__mulvdi3(-81985529216486895LL, 0, 0))
61 return 1;
63 if (test__mulvdi3(1, 1, 1))
64 return 1;
65 if (test__mulvdi3(1, 10, 10))
66 return 1;
67 if (test__mulvdi3(10, 1, 10))
68 return 1;
69 if (test__mulvdi3(1, 81985529216486895LL, 81985529216486895LL))
70 return 1;
71 if (test__mulvdi3(81985529216486895LL, 1, 81985529216486895LL))
72 return 1;
74 if (test__mulvdi3(1, -1, -1))
75 return 1;
76 if (test__mulvdi3(1, -10, -10))
77 return 1;
78 if (test__mulvdi3(-10, 1, -10))
79 return 1;
80 if (test__mulvdi3(1, -81985529216486895LL, -81985529216486895LL))
81 return 1;
82 if (test__mulvdi3(-81985529216486895LL, 1, -81985529216486895LL))
83 return 1;
85 if (test__mulvdi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
86 return 1;
87 if (test__mulvdi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
88 return 1;
89 if (test__mulvdi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
90 return 1;
91 if (test__mulvdi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
92 return 1;
94 if (test__mulvdi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
95 return 1;
96 if (test__mulvdi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
97 return 1;
98 if (test__mulvdi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
99 return 1;
100 if (test__mulvdi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
101 return 1;
103 if (test__mulvdi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
104 return 1;
105 if (test__mulvdi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
106 return 1;
107 if (test__mulvdi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
108 return 1;
109 if (test__mulvdi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
110 return 1;
112 // if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, -2, 0x8000000000000001LL)) // abort
113 // return 1;
114 // if (test__mulvdi3(-2, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL)) // abort
115 // return 1;
116 if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, -1, 0x8000000000000001LL))
117 return 1;
118 if (test__mulvdi3(-1, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL))
119 return 1;
120 if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, 0, 0))
121 return 1;
122 if (test__mulvdi3(0, 0x7FFFFFFFFFFFFFFFLL, 0))
123 return 1;
124 if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, 1, 0x7FFFFFFFFFFFFFFFLL))
125 return 1;
126 if (test__mulvdi3(1, 0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL))
127 return 1;
128 // if (test__mulvdi3(0x7FFFFFFFFFFFFFFFLL, 2, 0x8000000000000001LL)) // abort
129 // return 1;
130 // if (test__mulvdi3(2, 0x7FFFFFFFFFFFFFFFLL, 0x8000000000000001LL)) // abort
131 // return 1;
133 // if (test__mulvdi3(0x8000000000000000LL, -2, 0x8000000000000000LL)) // abort
134 // return 1;
135 // if (test__mulvdi3(-2, 0x8000000000000000LL, 0x8000000000000000LL)) // abort
136 // return 1;
137 // if (test__mulvdi3(0x8000000000000000LL, -1, 0x8000000000000000LL)) // abort
138 // return 1;
139 // if (test__mulvdi3(-1, 0x8000000000000000LL, 0x8000000000000000LL)) // abort
140 // return 1;
141 if (test__mulvdi3(0x8000000000000000LL, 0, 0))
142 return 1;
143 if (test__mulvdi3(0, 0x8000000000000000LL, 0))
144 return 1;
145 if (test__mulvdi3(0x8000000000000000LL, 1, 0x8000000000000000LL))
146 return 1;
147 if (test__mulvdi3(1, 0x8000000000000000LL, 0x8000000000000000LL))
148 return 1;
149 // if (test__mulvdi3(0x8000000000000000LL, 2, 0x8000000000000000LL)) // abort
150 // return 1;
151 // if (test__mulvdi3(2, 0x8000000000000000LL, 0x8000000000000000LL)) // abort
152 // return 1;
154 // if (test__mulvdi3(0x8000000000000001LL, -2, 0x8000000000000001LL)) // abort
155 // return 1;
156 // if (test__mulvdi3(-2, 0x8000000000000001LL, 0x8000000000000001LL)) // abort
157 // return 1;
158 if (test__mulvdi3(0x8000000000000001LL, -1, 0x7FFFFFFFFFFFFFFFLL))
159 return 1;
160 if (test__mulvdi3(-1, 0x8000000000000001LL, 0x7FFFFFFFFFFFFFFFLL))
161 return 1;
162 if (test__mulvdi3(0x8000000000000001LL, 0, 0))
163 return 1;
164 if (test__mulvdi3(0, 0x8000000000000001LL, 0))
165 return 1;
166 if (test__mulvdi3(0x8000000000000001LL, 1, 0x8000000000000001LL))
167 return 1;
168 if (test__mulvdi3(1, 0x8000000000000001LL, 0x8000000000000001LL))
169 return 1;
170 // if (test__mulvdi3(0x8000000000000001LL, 2, 0x8000000000000000LL)) // abort
171 // return 1;
172 // if (test__mulvdi3(2, 0x8000000000000001LL, 0x8000000000000000LL)) // abort
173 // return 1;
175 return 0;