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, 0
22 ; PPC64LE-NEXT: clrlwi 3, 3, 19
23 ; PPC64LE-NEXT: cmplwi 3, 1639
24 ; PPC64LE-NEXT: li 3, 1
25 ; PPC64LE-NEXT: isellt 3, 3, 4
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: lis 4, 146
57 ; PPC64LE-NEXT: rlwinm 5, 3, 31, 6, 31
58 ; PPC64LE-NEXT: rlwimi 5, 3, 26, 5, 5
59 ; PPC64LE-NEXT: ori 3, 4, 18725
60 ; PPC64LE-NEXT: li 4, 1
61 ; PPC64LE-NEXT: cmplw 5, 3
62 ; PPC64LE-NEXT: li 3, 0
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 5, 3, 1
86 ; PPC64LE-NEXT: li 4, 0
87 ; PPC64LE-NEXT: add 3, 3, 5
88 ; PPC64LE-NEXT: neg 3, 3
89 ; PPC64LE-NEXT: clrlwi 3, 3, 28
90 ; PPC64LE-NEXT: cmplwi 3, 3
91 ; PPC64LE-NEXT: li 3, 1
92 ; PPC64LE-NEXT: iselgt 3, 3, 4
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, 0
116 ; PPC64LE-NEXT: clrlwi 3, 3, 23
117 ; PPC64LE-NEXT: cmplwi 3, 1
118 ; PPC64LE-NEXT: li 3, 1
119 ; PPC64LE-NEXT: iselgt 3, 3, 4
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: mtvsrwz 34, 3
165 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_0@toc@ha
166 ; PPC64LE-NEXT: mtvsrwz 35, 4
167 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_0@toc@l
168 ; PPC64LE-NEXT: addis 4, 2, .LCPI4_2@toc@ha
169 ; PPC64LE-NEXT: mtvsrwz 36, 5
170 ; PPC64LE-NEXT: vmrghw 2, 3, 2
171 ; PPC64LE-NEXT: lvx 3, 0, 3
172 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_1@toc@ha
173 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_1@toc@l
174 ; PPC64LE-NEXT: vperm 2, 4, 2, 3
175 ; PPC64LE-NEXT: vspltisw 3, -11
176 ; PPC64LE-NEXT: lvx 4, 0, 3
177 ; PPC64LE-NEXT: addi 3, 4, .LCPI4_2@toc@l
178 ; PPC64LE-NEXT: addis 4, 2, .LCPI4_4@toc@ha
179 ; PPC64LE-NEXT: lvx 5, 0, 3
180 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_3@toc@ha
181 ; PPC64LE-NEXT: addi 4, 4, .LCPI4_4@toc@l
182 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_3@toc@l
183 ; PPC64LE-NEXT: vsrw 3, 3, 3
184 ; PPC64LE-NEXT: vsubuwm 2, 2, 4
185 ; PPC64LE-NEXT: lvx 4, 0, 3
186 ; PPC64LE-NEXT: addis 3, 2, .LCPI4_5@toc@ha
187 ; PPC64LE-NEXT: addi 3, 3, .LCPI4_5@toc@l
188 ; PPC64LE-NEXT: vmuluwm 2, 2, 5
189 ; PPC64LE-NEXT: lvx 5, 0, 4
190 ; PPC64LE-NEXT: xxland 32, 34, 35
191 ; PPC64LE-NEXT: vslw 2, 2, 4
192 ; PPC64LE-NEXT: vsrw 4, 0, 5
193 ; PPC64LE-NEXT: xxlor 0, 36, 34
194 ; PPC64LE-NEXT: lvx 2, 0, 3
195 ; PPC64LE-NEXT: xxland 35, 0, 35
196 ; PPC64LE-NEXT: vcmpgtuw 2, 3, 2
197 ; PPC64LE-NEXT: xxswapd 0, 34
198 ; PPC64LE-NEXT: xxsldwi 1, 34, 34, 1
199 ; PPC64LE-NEXT: mfvsrwz 5, 34
200 ; PPC64LE-NEXT: mffprwz 3, 0
201 ; PPC64LE-NEXT: mffprwz 4, 1
203 %urem = urem <3 x i11> %X, <i11 6, i11 7, i11 -5>
204 %cmp = icmp ne <3 x i11> %urem, <i11 0, i11 1, i11 2>
208 define i1 @test_urem_oversized(i66 %X) nounwind {
209 ; PPC-LABEL: test_urem_oversized:
212 ; PPC-NEXT: stw 0, 4(1)
213 ; PPC-NEXT: stwu 1, -16(1)
217 ; PPC-NEXT: lis 3, 12057
218 ; PPC-NEXT: lis 7, -12795
219 ; PPC-NEXT: ori 9, 3, 37186
220 ; PPC-NEXT: ori 10, 7, 40665
224 ; PPC-NEXT: bl __multi3
225 ; PPC-NEXT: rotlwi 7, 6, 31
226 ; PPC-NEXT: lis 3, -5526
227 ; PPC-NEXT: rlwimi 7, 5, 31, 0, 0
228 ; PPC-NEXT: rotlwi 5, 5, 31
229 ; PPC-NEXT: rlwimi 5, 4, 31, 0, 0
230 ; PPC-NEXT: ori 3, 3, 61135
231 ; PPC-NEXT: cmplwi 1, 5, 13
232 ; PPC-NEXT: cmplw 7, 3
233 ; PPC-NEXT: rlwinm 4, 4, 31, 31, 31
234 ; PPC-NEXT: crand 20, 6, 0
235 ; PPC-NEXT: crandc 21, 4, 6
236 ; PPC-NEXT: rlwimi. 4, 6, 1, 30, 30
237 ; PPC-NEXT: cror 20, 20, 21
238 ; PPC-NEXT: crnand 20, 2, 20
240 ; PPC-NEXT: bc 12, 20, .LBB5_1
241 ; PPC-NEXT: b .LBB5_2
245 ; PPC-NEXT: lwz 0, 20(1)
246 ; PPC-NEXT: addi 1, 1, 16
250 ; PPC64LE-LABEL: test_urem_oversized:
252 ; PPC64LE-NEXT: lis 5, 6028
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 5, 3, 5
260 ; PPC64LE-NEXT: sldi 3, 3, 1
261 ; PPC64LE-NEXT: add 3, 6, 3
262 ; PPC64LE-NEXT: add 3, 3, 4
263 ; PPC64LE-NEXT: lis 4, -8538
264 ; PPC64LE-NEXT: rotldi 6, 5, 63
265 ; PPC64LE-NEXT: ori 4, 4, 44780
266 ; PPC64LE-NEXT: rldimi 6, 3, 63, 0
267 ; PPC64LE-NEXT: rlwinm 3, 3, 31, 31, 31
268 ; PPC64LE-NEXT: rldicl 4, 4, 4, 28
269 ; PPC64LE-NEXT: rlwimi. 3, 5, 1, 30, 30
270 ; PPC64LE-NEXT: cmpld 1, 6, 4
271 ; PPC64LE-NEXT: li 3, 1
272 ; PPC64LE-NEXT: crnand 20, 2, 4
273 ; PPC64LE-NEXT: isel 3, 0, 3, 20
275 %urem = urem i66 %X, 1234567890
276 %cmp = icmp eq i66 %urem, 0