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
11 ; PPC-NEXT: cmplwi 3, 1639
13 ; PPC-NEXT: bclr 12, 0, 0
15 ; PPC-NEXT: ori 3, 4, 0
18 ; PPC64LE-LABEL: test_urem_odd:
20 ; PPC64LE-NEXT: mulli 3, 3, 3277
21 ; PPC64LE-NEXT: li 4, 1
22 ; PPC64LE-NEXT: clrlwi 3, 3, 19
23 ; PPC64LE-NEXT: cmplwi 3, 1639
24 ; PPC64LE-NEXT: li 3, 0
25 ; PPC64LE-NEXT: isellt 3, 4, 3
27 %urem = urem i13 %X, 5
28 %cmp = icmp eq i13 %urem, 0
32 define i1 @test_urem_even(i27 %X) nounwind {
33 ; PPC-LABEL: test_urem_even:
35 ; PPC-NEXT: lis 4, 1755
36 ; PPC-NEXT: ori 4, 4, 28087
37 ; PPC-NEXT: mullw 3, 3, 4
38 ; PPC-NEXT: rlwinm 4, 3, 31, 6, 31
39 ; PPC-NEXT: rlwimi 4, 3, 26, 5, 5
40 ; PPC-NEXT: lis 3, 146
41 ; PPC-NEXT: ori 3, 3, 18725
42 ; PPC-NEXT: cmplw 4, 3
45 ; PPC-NEXT: bc 12, 0, .LBB1_1
48 ; PPC-NEXT: addi 3, 4, 0
51 ; PPC64LE-LABEL: test_urem_even:
53 ; PPC64LE-NEXT: lis 4, 1755
54 ; PPC64LE-NEXT: ori 4, 4, 28087
55 ; PPC64LE-NEXT: mullw 3, 3, 4
56 ; PPC64LE-NEXT: rlwinm 4, 3, 31, 6, 31
57 ; PPC64LE-NEXT: rlwimi 4, 3, 26, 5, 5
58 ; PPC64LE-NEXT: lis 3, 146
59 ; PPC64LE-NEXT: ori 3, 3, 18725
60 ; PPC64LE-NEXT: cmplw 4, 3
61 ; PPC64LE-NEXT: li 3, 0
62 ; PPC64LE-NEXT: li 4, 1
63 ; PPC64LE-NEXT: isellt 3, 4, 3
65 %urem = urem i27 %X, 14
66 %cmp = icmp eq i27 %urem, 0
70 define i1 @test_urem_odd_setne(i4 %X) nounwind {
71 ; PPC-LABEL: test_urem_odd_setne:
73 ; PPC-NEXT: mulli 3, 3, 13
74 ; PPC-NEXT: clrlwi 3, 3, 28
76 ; PPC-NEXT: cmplwi 3, 3
78 ; PPC-NEXT: bclr 12, 1, 0
80 ; PPC-NEXT: ori 3, 4, 0
83 ; PPC64LE-LABEL: test_urem_odd_setne:
85 ; PPC64LE-NEXT: slwi 4, 3, 1
86 ; PPC64LE-NEXT: add 3, 3, 4
87 ; PPC64LE-NEXT: li 4, 1
88 ; PPC64LE-NEXT: neg 3, 3
89 ; PPC64LE-NEXT: clrlwi 3, 3, 28
90 ; PPC64LE-NEXT: cmplwi 3, 3
91 ; PPC64LE-NEXT: li 3, 0
92 ; PPC64LE-NEXT: iselgt 3, 4, 3
95 %cmp = icmp ne i4 %urem, 0
99 define i1 @test_urem_negative_odd(i9 %X) nounwind {
100 ; PPC-LABEL: test_urem_negative_odd:
102 ; PPC-NEXT: mulli 3, 3, 307
103 ; PPC-NEXT: clrlwi 3, 3, 23
105 ; PPC-NEXT: cmplwi 3, 1
107 ; PPC-NEXT: bclr 12, 1, 0
109 ; PPC-NEXT: ori 3, 4, 0
112 ; PPC64LE-LABEL: test_urem_negative_odd:
114 ; PPC64LE-NEXT: mulli 3, 3, 307
115 ; PPC64LE-NEXT: li 4, 1
116 ; PPC64LE-NEXT: clrlwi 3, 3, 23
117 ; PPC64LE-NEXT: cmplwi 3, 1
118 ; PPC64LE-NEXT: li 3, 0
119 ; PPC64LE-NEXT: iselgt 3, 4, 3
121 %urem = urem i9 %X, -5
122 %cmp = icmp ne i9 %urem, 0
126 define <3 x i1> @test_urem_vec(<3 x i11> %X) nounwind {
127 ; PPC-LABEL: test_urem_vec:
129 ; PPC-NEXT: mulli 3, 3, 683
130 ; PPC-NEXT: rlwinm 7, 3, 31, 22, 31
131 ; PPC-NEXT: rlwimi 7, 3, 10, 21, 21
132 ; PPC-NEXT: mulli 5, 5, 819
134 ; PPC-NEXT: cmplwi 7, 341
135 ; PPC-NEXT: mulli 3, 4, 1463
136 ; PPC-NEXT: addi 4, 5, -1638
137 ; PPC-NEXT: addi 3, 3, -1463
138 ; PPC-NEXT: clrlwi 4, 4, 21
139 ; PPC-NEXT: clrlwi 3, 3, 21
140 ; PPC-NEXT: cmplwi 1, 4, 1
141 ; PPC-NEXT: cmplwi 5, 3, 292
143 ; PPC-NEXT: bc 12, 21, .LBB4_2
145 ; PPC-NEXT: ori 4, 6, 0
146 ; PPC-NEXT: b .LBB4_3
148 ; PPC-NEXT: addi 4, 3, 0
150 ; PPC-NEXT: bc 12, 5, .LBB4_5
152 ; PPC-NEXT: ori 5, 6, 0
153 ; PPC-NEXT: b .LBB4_6
155 ; PPC-NEXT: addi 5, 3, 0
157 ; PPC-NEXT: bclr 12, 1, 0
159 ; PPC-NEXT: ori 3, 6, 0
162 ; PPC64LE-LABEL: test_urem_vec:
164 ; PPC64LE-NEXT: mtfprwz 0, 3
165 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_0@toc@ha
166 ; PPC64LE-NEXT: mtfprwz 1, 4
167 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_0@toc@l
168 ; PPC64LE-NEXT: mtvsrwz 36, 5
169 ; PPC64LE-NEXT: vspltisw 5, -11
170 ; PPC64LE-NEXT: lxvd2x 2, 0, 3
171 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_1@toc@ha
172 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_1@toc@l
173 ; PPC64LE-NEXT: xxmrghw 34, 1, 0
174 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
175 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_2@toc@ha
176 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_2@toc@l
177 ; PPC64LE-NEXT: xxswapd 35, 2
178 ; PPC64LE-NEXT: vperm 2, 4, 2, 3
179 ; PPC64LE-NEXT: xxswapd 35, 0
180 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
181 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_3@toc@ha
182 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_3@toc@l
183 ; PPC64LE-NEXT: vsubuwm 2, 2, 3
184 ; PPC64LE-NEXT: xxswapd 36, 0
185 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
186 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_4@toc@ha
187 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_4@toc@l
188 ; PPC64LE-NEXT: vmuluwm 2, 2, 4
189 ; PPC64LE-NEXT: vsrw 4, 5, 5
190 ; PPC64LE-NEXT: xxswapd 32, 0
191 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
192 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_5@toc@ha
193 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_5@toc@l
194 ; PPC64LE-NEXT: vslw 3, 2, 0
195 ; PPC64LE-NEXT: xxland 34, 34, 36
196 ; PPC64LE-NEXT: xxswapd 33, 0
197 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
198 ; PPC64LE-NEXT: vsrw 2, 2, 1
199 ; PPC64LE-NEXT: xxswapd 38, 0
200 ; PPC64LE-NEXT: xxlor 0, 34, 35
201 ; PPC64LE-NEXT: xxland 34, 0, 36
202 ; PPC64LE-NEXT: vcmpgtuw 2, 2, 6
203 ; PPC64LE-NEXT: mfvsrwz 5, 34
204 ; PPC64LE-NEXT: xxswapd 0, 34
205 ; PPC64LE-NEXT: xxsldwi 1, 34, 34, 1
206 ; PPC64LE-NEXT: mffprwz 3, 0
207 ; PPC64LE-NEXT: mffprwz 4, 1
209 %urem = urem <3 x i11> %X, <i11 6, i11 7, i11 -5>
210 %cmp = icmp ne <3 x i11> %urem, <i11 0, i11 1, i11 2>
214 define i1 @test_urem_oversized(i66 %X) nounwind {
215 ; PPC-LABEL: test_urem_oversized:
217 ; PPC-NEXT: lis 6, -12795
218 ; PPC-NEXT: ori 6, 6, 40665
219 ; PPC-NEXT: mulhwu 7, 5, 6
220 ; PPC-NEXT: lis 9, 12057
221 ; PPC-NEXT: ori 9, 9, 37186
222 ; PPC-NEXT: mullw 11, 4, 6
223 ; PPC-NEXT: addc 7, 11, 7
224 ; PPC-NEXT: lis 11, -5526
225 ; PPC-NEXT: ori 11, 11, 61135
226 ; PPC-NEXT: mulhwu 8, 4, 6
227 ; PPC-NEXT: addze 8, 8
228 ; PPC-NEXT: mulhwu 10, 5, 9
229 ; PPC-NEXT: mullw 4, 4, 9
230 ; PPC-NEXT: mullw 9, 5, 9
231 ; PPC-NEXT: addc 7, 9, 7
232 ; PPC-NEXT: addze 9, 10
233 ; PPC-NEXT: rotlwi 10, 7, 31
234 ; PPC-NEXT: mullw 3, 3, 6
235 ; PPC-NEXT: mullw 6, 5, 6
236 ; PPC-NEXT: slwi 5, 5, 1
237 ; PPC-NEXT: add 3, 5, 3
238 ; PPC-NEXT: rotlwi 5, 6, 31
239 ; PPC-NEXT: rlwimi 5, 7, 31, 0, 0
240 ; PPC-NEXT: add 7, 8, 9
241 ; PPC-NEXT: add 4, 4, 7
242 ; PPC-NEXT: add 3, 4, 3
243 ; PPC-NEXT: rlwimi 10, 3, 31, 0, 0
244 ; PPC-NEXT: cmplw 5, 11
245 ; PPC-NEXT: cmplwi 1, 10, 13
246 ; PPC-NEXT: rlwinm 3, 3, 31, 31, 31
247 ; PPC-NEXT: crand 20, 6, 0
248 ; PPC-NEXT: crandc 21, 4, 6
249 ; PPC-NEXT: rlwimi. 3, 6, 1, 30, 30
250 ; PPC-NEXT: cror 20, 20, 21
251 ; PPC-NEXT: crnand 20, 2, 20
253 ; PPC-NEXT: bc 12, 20, .LBB5_1
259 ; PPC64LE-LABEL: test_urem_oversized:
261 ; PPC64LE-NEXT: lis 5, 6028
262 ; PPC64LE-NEXT: sldi 7, 3, 1
263 ; PPC64LE-NEXT: ori 5, 5, 51361
264 ; PPC64LE-NEXT: rldic 5, 5, 33, 2
265 ; PPC64LE-NEXT: oris 5, 5, 52741
266 ; PPC64LE-NEXT: ori 5, 5, 40665
267 ; PPC64LE-NEXT: mulhdu 6, 3, 5
268 ; PPC64LE-NEXT: mulld 4, 4, 5
269 ; PPC64LE-NEXT: mulld 3, 3, 5
270 ; PPC64LE-NEXT: add 6, 6, 7
271 ; PPC64LE-NEXT: rotldi 5, 3, 63
272 ; PPC64LE-NEXT: add 4, 6, 4
273 ; PPC64LE-NEXT: lis 6, -8538
274 ; PPC64LE-NEXT: ori 6, 6, 44780
275 ; PPC64LE-NEXT: rldimi 5, 4, 63, 0
276 ; PPC64LE-NEXT: rlwinm 4, 4, 31, 31, 31
277 ; PPC64LE-NEXT: rldicl 6, 6, 4, 28
278 ; PPC64LE-NEXT: rlwimi. 4, 3, 1, 30, 30
279 ; PPC64LE-NEXT: li 3, 1
280 ; PPC64LE-NEXT: cmpld 1, 5, 6
281 ; PPC64LE-NEXT: crnand 20, 2, 4
282 ; PPC64LE-NEXT: isel 3, 0, 3, 20
284 %urem = urem i66 %X, 1234567890
285 %cmp = icmp eq i66 %urem, 0