[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / udivsi3_test.c
blob4ac727941f60cb8cb5309816deb7dd474d3398b2
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_udivsi3
3 //===-- udivsi3_test.c - Test __udivsi3 -----------------------------------===//
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 __udivsi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 // Returns: a / b
20 COMPILER_RT_ABI su_int __udivsi3(su_int a, su_int b);
22 int test__udivsi3(su_int a, su_int b, su_int expected_q)
24 su_int q = __udivsi3(a, b);
25 if (q != expected_q)
26 printf("error in __udivsi3: %X / %X = %X, expected %X\n",
27 a, b, q, expected_q);
28 return q != expected_q;
31 su_int tests[][4] =
33 {0x00000000, 0x00000001, 0x00000000},
34 {0x00000000, 0x00000002, 0x00000000},
35 {0x00000000, 0x00000003, 0x00000000},
36 {0x00000000, 0x00000010, 0x00000000},
37 {0x00000000, 0x078644FA, 0x00000000},
38 {0x00000000, 0x0747AE14, 0x00000000},
39 {0x00000000, 0x7FFFFFFF, 0x00000000},
40 {0x00000000, 0x80000000, 0x00000000},
41 {0x00000000, 0xFFFFFFFD, 0x00000000},
42 {0x00000000, 0xFFFFFFFE, 0x00000000},
43 {0x00000000, 0xFFFFFFFF, 0x00000000},
44 {0x00000001, 0x00000001, 0x00000001},
45 {0x00000001, 0x00000002, 0x00000000},
46 {0x00000001, 0x00000003, 0x00000000},
47 {0x00000001, 0x00000010, 0x00000000},
48 {0x00000001, 0x078644FA, 0x00000000},
49 {0x00000001, 0x0747AE14, 0x00000000},
50 {0x00000001, 0x7FFFFFFF, 0x00000000},
51 {0x00000001, 0x80000000, 0x00000000},
52 {0x00000001, 0xFFFFFFFD, 0x00000000},
53 {0x00000001, 0xFFFFFFFE, 0x00000000},
54 {0x00000001, 0xFFFFFFFF, 0x00000000},
55 {0x00000002, 0x00000001, 0x00000002},
56 {0x00000002, 0x00000002, 0x00000001},
57 {0x00000002, 0x00000003, 0x00000000},
58 {0x00000002, 0x00000010, 0x00000000},
59 {0x00000002, 0x078644FA, 0x00000000},
60 {0x00000002, 0x0747AE14, 0x00000000},
61 {0x00000002, 0x7FFFFFFF, 0x00000000},
62 {0x00000002, 0x80000000, 0x00000000},
63 {0x00000002, 0xFFFFFFFD, 0x00000000},
64 {0x00000002, 0xFFFFFFFE, 0x00000000},
65 {0x00000002, 0xFFFFFFFF, 0x00000000},
66 {0x00000003, 0x00000001, 0x00000003},
67 {0x00000003, 0x00000002, 0x00000001},
68 {0x00000003, 0x00000003, 0x00000001},
69 {0x00000003, 0x00000010, 0x00000000},
70 {0x00000003, 0x078644FA, 0x00000000},
71 {0x00000003, 0x0747AE14, 0x00000000},
72 {0x00000003, 0x7FFFFFFF, 0x00000000},
73 {0x00000003, 0x80000000, 0x00000000},
74 {0x00000003, 0xFFFFFFFD, 0x00000000},
75 {0x00000003, 0xFFFFFFFE, 0x00000000},
76 {0x00000003, 0xFFFFFFFF, 0x00000000},
77 {0x00000010, 0x00000001, 0x00000010},
78 {0x00000010, 0x00000002, 0x00000008},
79 {0x00000010, 0x00000003, 0x00000005},
80 {0x00000010, 0x00000010, 0x00000001},
81 {0x00000010, 0x078644FA, 0x00000000},
82 {0x00000010, 0x0747AE14, 0x00000000},
83 {0x00000010, 0x7FFFFFFF, 0x00000000},
84 {0x00000010, 0x80000000, 0x00000000},
85 {0x00000010, 0xFFFFFFFD, 0x00000000},
86 {0x00000010, 0xFFFFFFFE, 0x00000000},
87 {0x00000010, 0xFFFFFFFF, 0x00000000},
88 {0x078644FA, 0x00000001, 0x078644FA},
89 {0x078644FA, 0x00000002, 0x03C3227D},
90 {0x078644FA, 0x00000003, 0x028216FE},
91 {0x078644FA, 0x00000010, 0x0078644F},
92 {0x078644FA, 0x078644FA, 0x00000001},
93 {0x078644FA, 0x0747AE14, 0x00000001},
94 {0x078644FA, 0x7FFFFFFF, 0x00000000},
95 {0x078644FA, 0x80000000, 0x00000000},
96 {0x078644FA, 0xFFFFFFFD, 0x00000000},
97 {0x078644FA, 0xFFFFFFFE, 0x00000000},
98 {0x078644FA, 0xFFFFFFFF, 0x00000000},
99 {0x0747AE14, 0x00000001, 0x0747AE14},
100 {0x0747AE14, 0x00000002, 0x03A3D70A},
101 {0x0747AE14, 0x00000003, 0x026D3A06},
102 {0x0747AE14, 0x00000010, 0x00747AE1},
103 {0x0747AE14, 0x078644FA, 0x00000000},
104 {0x0747AE14, 0x0747AE14, 0x00000001},
105 {0x0747AE14, 0x7FFFFFFF, 0x00000000},
106 {0x0747AE14, 0x80000000, 0x00000000},
107 {0x0747AE14, 0xFFFFFFFD, 0x00000000},
108 {0x0747AE14, 0xFFFFFFFE, 0x00000000},
109 {0x0747AE14, 0xFFFFFFFF, 0x00000000},
110 {0x7FFFFFFF, 0x00000001, 0x7FFFFFFF},
111 {0x7FFFFFFF, 0x00000002, 0x3FFFFFFF},
112 {0x7FFFFFFF, 0x00000003, 0x2AAAAAAA},
113 {0x7FFFFFFF, 0x00000010, 0x07FFFFFF},
114 {0x7FFFFFFF, 0x078644FA, 0x00000011},
115 {0x7FFFFFFF, 0x0747AE14, 0x00000011},
116 {0x7FFFFFFF, 0x7FFFFFFF, 0x00000001},
117 {0x7FFFFFFF, 0x80000000, 0x00000000},
118 {0x7FFFFFFF, 0xFFFFFFFD, 0x00000000},
119 {0x7FFFFFFF, 0xFFFFFFFE, 0x00000000},
120 {0x7FFFFFFF, 0xFFFFFFFF, 0x00000000},
121 {0x80000000, 0x00000001, 0x80000000},
122 {0x80000000, 0x00000002, 0x40000000},
123 {0x80000000, 0x00000003, 0x2AAAAAAA},
124 {0x80000000, 0x00000010, 0x08000000},
125 {0x80000000, 0x078644FA, 0x00000011},
126 {0x80000000, 0x0747AE14, 0x00000011},
127 {0x80000000, 0x7FFFFFFF, 0x00000001},
128 {0x80000000, 0x80000000, 0x00000001},
129 {0x80000000, 0xFFFFFFFD, 0x00000000},
130 {0x80000000, 0xFFFFFFFE, 0x00000000},
131 {0x80000000, 0xFFFFFFFF, 0x00000000},
132 {0xFFFFFFFD, 0x00000001, 0xFFFFFFFD},
133 {0xFFFFFFFD, 0x00000002, 0x7FFFFFFE},
134 {0xFFFFFFFD, 0x00000003, 0x55555554},
135 {0xFFFFFFFD, 0x00000010, 0x0FFFFFFF},
136 {0xFFFFFFFD, 0x078644FA, 0x00000022},
137 {0xFFFFFFFD, 0x0747AE14, 0x00000023},
138 {0xFFFFFFFD, 0x7FFFFFFF, 0x00000001},
139 {0xFFFFFFFD, 0x80000000, 0x00000001},
140 {0xFFFFFFFD, 0xFFFFFFFD, 0x00000001},
141 {0xFFFFFFFD, 0xFFFFFFFE, 0x00000000},
142 {0xFFFFFFFD, 0xFFFFFFFF, 0x00000000},
143 {0xFFFFFFFE, 0x00000001, 0xFFFFFFFE},
144 {0xFFFFFFFE, 0x00000002, 0x7FFFFFFF},
145 {0xFFFFFFFE, 0x00000003, 0x55555554},
146 {0xFFFFFFFE, 0x00000010, 0x0FFFFFFF},
147 {0xFFFFFFFE, 0x078644FA, 0x00000022},
148 {0xFFFFFFFE, 0x0747AE14, 0x00000023},
149 {0xFFFFFFFE, 0x7FFFFFFF, 0x00000002},
150 {0xFFFFFFFE, 0x80000000, 0x00000001},
151 {0xFFFFFFFE, 0xFFFFFFFD, 0x00000001},
152 {0xFFFFFFFE, 0xFFFFFFFE, 0x00000001},
153 {0xFFFFFFFE, 0xFFFFFFFF, 0x00000000},
154 {0xFFFFFFFF, 0x00000001, 0xFFFFFFFF},
155 {0xFFFFFFFF, 0x00000002, 0x7FFFFFFF},
156 {0xFFFFFFFF, 0x00000003, 0x55555555},
157 {0xFFFFFFFF, 0x00000010, 0x0FFFFFFF},
158 {0xFFFFFFFF, 0x078644FA, 0x00000022},
159 {0xFFFFFFFF, 0x0747AE14, 0x00000023},
160 {0xFFFFFFFF, 0x7FFFFFFF, 0x00000002},
161 {0xFFFFFFFF, 0x80000000, 0x00000001},
162 {0xFFFFFFFF, 0xFFFFFFFD, 0x00000001},
163 {0xFFFFFFFF, 0xFFFFFFFE, 0x00000001},
164 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000001}
167 int main()
169 const unsigned N = sizeof(tests) / sizeof(tests[0]);
170 unsigned i;
171 for (i = 0; i < N; ++i)
172 if (test__udivsi3(tests[i][0], tests[i][1], tests[i][2]))
173 return 1;
175 return 0;