1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=powerpc-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=PPC
3 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=PPC64LE
5 define i1 @test_urem_odd(i13 %X) nounwind {
6 ; PPC-LABEL: test_urem_odd:
8 ; PPC-NEXT: mulli 3, 3, 3277
9 ; PPC-NEXT: clrlwi 3, 3, 19
10 ; PPC-NEXT: cmplwi 3, 1639
12 ; PPC-NEXT: bclr 12, 0, 0
17 ; PPC64LE-LABEL: test_urem_odd:
19 ; PPC64LE-NEXT: mulli 3, 3, 3277
20 ; PPC64LE-NEXT: li 4, 1
21 ; PPC64LE-NEXT: clrlwi 3, 3, 19
22 ; PPC64LE-NEXT: cmplwi 3, 1639
23 ; PPC64LE-NEXT: li 3, 0
24 ; PPC64LE-NEXT: isellt 3, 4, 3
26 %urem = urem i13 %X, 5
27 %cmp = icmp eq i13 %urem, 0
31 define i1 @test_urem_even(i27 %X) nounwind {
32 ; PPC-LABEL: test_urem_even:
34 ; PPC-NEXT: lis 4, 1755
35 ; PPC-NEXT: ori 4, 4, 28087
36 ; PPC-NEXT: mullw 3, 3, 4
37 ; PPC-NEXT: rlwinm 4, 3, 31, 6, 31
38 ; PPC-NEXT: rlwimi 4, 3, 26, 5, 5
39 ; PPC-NEXT: lis 3, 146
40 ; PPC-NEXT: ori 3, 3, 18725
41 ; PPC-NEXT: cmplw 4, 3
43 ; PPC-NEXT: bclr 12, 0, 0
48 ; PPC64LE-LABEL: test_urem_even:
50 ; PPC64LE-NEXT: lis 4, 1755
51 ; PPC64LE-NEXT: ori 4, 4, 28087
52 ; PPC64LE-NEXT: mullw 3, 3, 4
53 ; PPC64LE-NEXT: rlwinm 4, 3, 31, 6, 31
54 ; PPC64LE-NEXT: rlwimi 4, 3, 26, 5, 5
55 ; PPC64LE-NEXT: lis 3, 146
56 ; PPC64LE-NEXT: ori 3, 3, 18725
57 ; PPC64LE-NEXT: cmplw 4, 3
58 ; PPC64LE-NEXT: li 3, 0
59 ; PPC64LE-NEXT: li 4, 1
60 ; PPC64LE-NEXT: isellt 3, 4, 3
62 %urem = urem i27 %X, 14
63 %cmp = icmp eq i27 %urem, 0
67 define i1 @test_urem_odd_setne(i4 %X) nounwind {
68 ; PPC-LABEL: test_urem_odd_setne:
70 ; PPC-NEXT: mulli 3, 3, 13
71 ; PPC-NEXT: clrlwi 3, 3, 28
72 ; PPC-NEXT: cmplwi 3, 3
74 ; PPC-NEXT: bclr 12, 1, 0
79 ; PPC64LE-LABEL: test_urem_odd_setne:
81 ; PPC64LE-NEXT: slwi 4, 3, 1
82 ; PPC64LE-NEXT: add 3, 3, 4
83 ; PPC64LE-NEXT: li 4, 1
84 ; PPC64LE-NEXT: neg 3, 3
85 ; PPC64LE-NEXT: clrlwi 3, 3, 28
86 ; PPC64LE-NEXT: cmplwi 3, 3
87 ; PPC64LE-NEXT: li 3, 0
88 ; PPC64LE-NEXT: iselgt 3, 4, 3
91 %cmp = icmp ne i4 %urem, 0
95 define i1 @test_urem_negative_odd(i9 %X) nounwind {
96 ; PPC-LABEL: test_urem_negative_odd:
98 ; PPC-NEXT: mulli 3, 3, 307
99 ; PPC-NEXT: clrlwi 3, 3, 23
100 ; PPC-NEXT: cmplwi 3, 1
102 ; PPC-NEXT: bclr 12, 1, 0
107 ; PPC64LE-LABEL: test_urem_negative_odd:
109 ; PPC64LE-NEXT: mulli 3, 3, 307
110 ; PPC64LE-NEXT: li 4, 1
111 ; PPC64LE-NEXT: clrlwi 3, 3, 23
112 ; PPC64LE-NEXT: cmplwi 3, 1
113 ; PPC64LE-NEXT: li 3, 0
114 ; PPC64LE-NEXT: iselgt 3, 4, 3
116 %urem = urem i9 %X, -5
117 %cmp = icmp ne i9 %urem, 0
121 define <3 x i1> @test_urem_vec(<3 x i11> %X) nounwind {
122 ; PPC-LABEL: test_urem_vec:
125 ; PPC-NEXT: mulli 6, 6, 683
126 ; PPC-NEXT: rlwinm 7, 6, 31, 22, 31
127 ; PPC-NEXT: rlwimi 7, 6, 10, 21, 21
128 ; PPC-NEXT: mulli 5, 5, 819
129 ; PPC-NEXT: addi 5, 5, -1638
130 ; PPC-NEXT: clrlwi 5, 5, 21
131 ; PPC-NEXT: mulli 4, 4, 1463
132 ; PPC-NEXT: addi 4, 4, -1463
133 ; PPC-NEXT: clrlwi 4, 4, 21
135 ; PPC-NEXT: cmplwi 7, 341
136 ; PPC-NEXT: cmplwi 1, 5, 1
137 ; PPC-NEXT: cmplwi 5, 4, 292
139 ; PPC-NEXT: bc 12, 21, .LBB4_2
144 ; PPC-NEXT: bc 12, 5, .LBB4_4
148 ; PPC-NEXT: bclr 12, 1, 0
153 ; PPC64LE-LABEL: test_urem_vec:
155 ; PPC64LE-NEXT: mtfprwz 0, 3
156 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_0@toc@ha
157 ; PPC64LE-NEXT: mtfprwz 1, 4
158 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_0@toc@l
159 ; PPC64LE-NEXT: mtvsrwz 36, 5
160 ; PPC64LE-NEXT: vspltisw 5, -11
161 ; PPC64LE-NEXT: lxvd2x 2, 0, 3
162 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_1@toc@ha
163 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_1@toc@l
164 ; PPC64LE-NEXT: xxmrghw 34, 1, 0
165 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
166 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_2@toc@ha
167 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_2@toc@l
168 ; PPC64LE-NEXT: xxswapd 35, 2
169 ; PPC64LE-NEXT: vperm 2, 4, 2, 3
170 ; PPC64LE-NEXT: xxswapd 35, 0
171 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
172 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_3@toc@ha
173 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_3@toc@l
174 ; PPC64LE-NEXT: vsubuwm 2, 2, 3
175 ; PPC64LE-NEXT: xxswapd 36, 0
176 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
177 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_4@toc@ha
178 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_4@toc@l
179 ; PPC64LE-NEXT: vmuluwm 2, 2, 4
180 ; PPC64LE-NEXT: vsrw 4, 5, 5
181 ; PPC64LE-NEXT: xxswapd 32, 0
182 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
183 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_5@toc@ha
184 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_5@toc@l
185 ; PPC64LE-NEXT: vslw 3, 2, 0
186 ; PPC64LE-NEXT: xxland 34, 34, 36
187 ; PPC64LE-NEXT: xxswapd 33, 0
188 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
189 ; PPC64LE-NEXT: vsrw 2, 2, 1
190 ; PPC64LE-NEXT: xxswapd 38, 0
191 ; PPC64LE-NEXT: xxlor 0, 34, 35
192 ; PPC64LE-NEXT: xxland 34, 0, 36
193 ; PPC64LE-NEXT: vcmpgtuw 2, 2, 6
194 ; PPC64LE-NEXT: mfvsrwz 5, 34
195 ; PPC64LE-NEXT: xxswapd 0, 34
196 ; PPC64LE-NEXT: xxsldwi 1, 34, 34, 1
197 ; PPC64LE-NEXT: mffprwz 3, 0
198 ; PPC64LE-NEXT: mffprwz 4, 1
200 %urem = urem <3 x i11> %X, <i11 6, i11 7, i11 -5>
201 %cmp = icmp ne <3 x i11> %urem, <i11 0, i11 1, i11 2>
205 define i1 @test_urem_oversized(i66 %X) nounwind {
206 ; PPC-LABEL: test_urem_oversized:
208 ; PPC-NEXT: lis 6, -12795
209 ; PPC-NEXT: ori 6, 6, 40665
210 ; PPC-NEXT: mulhwu 7, 5, 6
211 ; PPC-NEXT: lis 9, 12057
212 ; PPC-NEXT: ori 9, 9, 37186
213 ; PPC-NEXT: mullw 11, 4, 6
214 ; PPC-NEXT: addc 7, 11, 7
215 ; PPC-NEXT: lis 11, -5526
216 ; PPC-NEXT: ori 11, 11, 61135
217 ; PPC-NEXT: mulhwu 8, 4, 6
218 ; PPC-NEXT: addze 8, 8
219 ; PPC-NEXT: mulhwu 10, 5, 9
220 ; PPC-NEXT: mullw 4, 4, 9
221 ; PPC-NEXT: mullw 9, 5, 9
222 ; PPC-NEXT: addc 7, 9, 7
223 ; PPC-NEXT: addze 9, 10
224 ; PPC-NEXT: rotlwi 10, 7, 31
225 ; PPC-NEXT: mullw 3, 3, 6
226 ; PPC-NEXT: mullw 6, 5, 6
227 ; PPC-NEXT: slwi 5, 5, 1
228 ; PPC-NEXT: add 3, 5, 3
229 ; PPC-NEXT: rotlwi 5, 6, 31
230 ; PPC-NEXT: rlwimi 5, 7, 31, 0, 0
231 ; PPC-NEXT: add 7, 8, 9
232 ; PPC-NEXT: add 4, 4, 7
233 ; PPC-NEXT: add 3, 4, 3
234 ; PPC-NEXT: rlwimi 10, 3, 31, 0, 0
235 ; PPC-NEXT: cmplw 5, 11
236 ; PPC-NEXT: cmplwi 1, 10, 13
237 ; PPC-NEXT: rlwinm 3, 3, 31, 31, 31
238 ; PPC-NEXT: crandc 20, 4, 6
239 ; PPC-NEXT: crand 21, 6, 0
240 ; PPC-NEXT: rlwimi. 3, 6, 1, 30, 30
241 ; PPC-NEXT: cror 20, 21, 20
242 ; PPC-NEXT: crnand 20, 2, 20
244 ; PPC-NEXT: bclr 12, 20, 0
249 ; PPC64LE-LABEL: test_urem_oversized:
251 ; PPC64LE-NEXT: lis 5, 6028
252 ; PPC64LE-NEXT: sldi 7, 3, 1
253 ; PPC64LE-NEXT: ori 5, 5, 51361
254 ; PPC64LE-NEXT: rldic 5, 5, 33, 2
255 ; PPC64LE-NEXT: oris 5, 5, 52741
256 ; PPC64LE-NEXT: ori 5, 5, 40665
257 ; PPC64LE-NEXT: mulhdu 6, 3, 5
258 ; PPC64LE-NEXT: mulld 4, 4, 5
259 ; PPC64LE-NEXT: mulld 3, 3, 5
260 ; PPC64LE-NEXT: add 6, 6, 7
261 ; PPC64LE-NEXT: rotldi 5, 3, 63
262 ; PPC64LE-NEXT: add 4, 6, 4
263 ; PPC64LE-NEXT: lis 6, -8538
264 ; PPC64LE-NEXT: ori 6, 6, 44780
265 ; PPC64LE-NEXT: rldimi 5, 4, 63, 0
266 ; PPC64LE-NEXT: rlwinm 4, 4, 31, 31, 31
267 ; PPC64LE-NEXT: rldicl 6, 6, 4, 28
268 ; PPC64LE-NEXT: rlwimi. 4, 3, 1, 30, 30
269 ; PPC64LE-NEXT: li 3, 1
270 ; PPC64LE-NEXT: cmpld 1, 5, 6
271 ; PPC64LE-NEXT: crnand 20, 2, 4
272 ; PPC64LE-NEXT: isel 3, 0, 3, 20
274 %urem = urem i66 %X, 1234567890
275 %cmp = icmp eq i66 %urem, 0