[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / mulvsi3_test.c
blobf1ef8b12bdb3e70805c7b4078730efc8523b0c22
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_mulvsi3
3 //===-- mulvsi3_test.c - Test __mulvsi3 -----------------------------------===//
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 __mulvsi3 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 __mulvsi3(si_int a, si_int b);
24 int test__mulvsi3(si_int a, si_int b, si_int expected)
26 si_int x = __mulvsi3(a, b);
27 if (x != expected)
28 printf("error in __mulvsi3: %d * %d = %d, expected %d\n",
29 a, b, x, expected);
30 return x != expected;
33 int main()
35 if (test__mulvsi3(0, 0, 0))
36 return 1;
37 if (test__mulvsi3(0, 1, 0))
38 return 1;
39 if (test__mulvsi3(1, 0, 0))
40 return 1;
41 if (test__mulvsi3(0, 10, 0))
42 return 1;
43 if (test__mulvsi3(10, 0, 0))
44 return 1;
45 if (test__mulvsi3(0, 0x1234567, 0))
46 return 1;
47 if (test__mulvsi3(0x1234567, 0, 0))
48 return 1;
50 if (test__mulvsi3(0, -1, 0))
51 return 1;
52 if (test__mulvsi3(-1, 0, 0))
53 return 1;
54 if (test__mulvsi3(0, -10, 0))
55 return 1;
56 if (test__mulvsi3(-10, 0, 0))
57 return 1;
58 if (test__mulvsi3(0, -0x1234567, 0))
59 return 1;
60 if (test__mulvsi3(-0x1234567, 0, 0))
61 return 1;
63 if (test__mulvsi3(1, 1, 1))
64 return 1;
65 if (test__mulvsi3(1, 10, 10))
66 return 1;
67 if (test__mulvsi3(10, 1, 10))
68 return 1;
69 if (test__mulvsi3(1, 0x1234567, 0x1234567))
70 return 1;
71 if (test__mulvsi3(0x1234567, 1, 0x1234567))
72 return 1;
74 if (test__mulvsi3(1, -1, -1))
75 return 1;
76 if (test__mulvsi3(1, -10, -10))
77 return 1;
78 if (test__mulvsi3(-10, 1, -10))
79 return 1;
80 if (test__mulvsi3(1, -0x1234567, -0x1234567))
81 return 1;
82 if (test__mulvsi3(-0x1234567, 1, -0x1234567))
83 return 1;
85 // if (test__mulvsi3(0x7FFFFFFF, -2, 0x80000001)) // abort
86 // return 1;
87 // if (test__mulvsi3(-2, 0x7FFFFFFF, 0x80000001)) // abort
88 // return 1;
89 if (test__mulvsi3(0x7FFFFFFF, -1, 0x80000001))
90 return 1;
91 if (test__mulvsi3(-1, 0x7FFFFFFF, 0x80000001))
92 return 1;
93 if (test__mulvsi3(0x7FFFFFFF, 0, 0))
94 return 1;
95 if (test__mulvsi3(0, 0x7FFFFFFF, 0))
96 return 1;
97 if (test__mulvsi3(0x7FFFFFFF, 1, 0x7FFFFFFF))
98 return 1;
99 if (test__mulvsi3(1, 0x7FFFFFFF, 0x7FFFFFFF))
100 return 1;
101 // if (test__mulvsi3(0x7FFFFFFF, 2, 0x80000001)) // abort
102 // return 1;
103 // if (test__mulvsi3(2, 0x7FFFFFFF, 0x80000001)) // abort
104 // return 1;
106 // if (test__mulvsi3(0x80000000, -2, 0x80000000)) // abort
107 // return 1;
108 // if (test__mulvsi3(-2, 0x80000000, 0x80000000)) // abort
109 // return 1;
110 // if (test__mulvsi3(0x80000000, -1, 0x80000000)) // abort
111 // return 1;
112 // if (test__mulvsi3(-1, 0x80000000, 0x80000000)) // abort
113 // return 1;
114 if (test__mulvsi3(0x80000000, 0, 0))
115 return 1;
116 if (test__mulvsi3(0, 0x80000000, 0))
117 return 1;
118 if (test__mulvsi3(0x80000000, 1, 0x80000000))
119 return 1;
120 if (test__mulvsi3(1, 0x80000000, 0x80000000))
121 return 1;
122 // if (test__mulvsi3(0x80000000, 2, 0x80000000)) // abort
123 // return 1;
124 // if (test__mulvsi3(2, 0x80000000, 0x80000000)) // abort
125 // return 1;
127 // if (test__mulvsi3(0x80000001, -2, 0x80000001)) // abort
128 // return 1;
129 // if (test__mulvsi3(-2, 0x80000001, 0x80000001)) // abort
130 // return 1;
131 if (test__mulvsi3(0x80000001, -1, 0x7FFFFFFF))
132 return 1;
133 if (test__mulvsi3(-1, 0x80000001, 0x7FFFFFFF))
134 return 1;
135 if (test__mulvsi3(0x80000001, 0, 0))
136 return 1;
137 if (test__mulvsi3(0, 0x80000001, 0))
138 return 1;
139 if (test__mulvsi3(0x80000001, 1, 0x80000001))
140 return 1;
141 if (test__mulvsi3(1, 0x80000001, 0x80000001))
142 return 1;
143 // if (test__mulvsi3(0x80000001, 2, 0x80000000)) // abort
144 // return 1;
145 // if (test__mulvsi3(2, 0x80000001, 0x80000000)) // abort
146 // return 1;
148 return 0;