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_srem_odd(i29 %X) nounwind {
6 ; PPC-LABEL: test_srem_odd:
8 ; PPC-NEXT: lis 4, 8026
9 ; PPC-NEXT: ori 4, 4, 33099
10 ; PPC-NEXT: mullw 3, 3, 4
11 ; PPC-NEXT: addi 3, 3, 24493
13 ; PPC-NEXT: addis 3, 3, 41
14 ; PPC-NEXT: ori 4, 4, 48987
15 ; PPC-NEXT: clrlwi 3, 3, 3
16 ; PPC-NEXT: cmplw 3, 4
19 ; PPC-NEXT: bc 12, 0, .LBB0_1
22 ; PPC-NEXT: addi 3, 4, 0
25 ; PPC64LE-LABEL: test_srem_odd:
27 ; PPC64LE-NEXT: lis 4, 8026
28 ; PPC64LE-NEXT: ori 4, 4, 33099
29 ; PPC64LE-NEXT: mullw 3, 3, 4
30 ; PPC64LE-NEXT: lis 4, 82
31 ; PPC64LE-NEXT: ori 4, 4, 48987
32 ; PPC64LE-NEXT: addi 3, 3, 24493
33 ; PPC64LE-NEXT: addis 3, 3, 41
34 ; PPC64LE-NEXT: clrlwi 3, 3, 3
35 ; PPC64LE-NEXT: cmplw 3, 4
36 ; PPC64LE-NEXT: li 3, 0
37 ; PPC64LE-NEXT: li 4, 1
38 ; PPC64LE-NEXT: isellt 3, 4, 3
40 %srem = srem i29 %X, 99
41 %cmp = icmp eq i29 %srem, 0
45 define i1 @test_srem_even(i4 %X) nounwind {
46 ; PPC-LABEL: test_srem_even:
48 ; PPC-NEXT: lis 4, 10922
49 ; PPC-NEXT: slwi 3, 3, 28
50 ; PPC-NEXT: ori 4, 4, 43691
51 ; PPC-NEXT: srawi 3, 3, 28
52 ; PPC-NEXT: mulhw 4, 3, 4
53 ; PPC-NEXT: srwi 5, 4, 31
54 ; PPC-NEXT: add 4, 4, 5
56 ; PPC-NEXT: mulli 4, 4, 6
57 ; PPC-NEXT: sub 3, 3, 4
58 ; PPC-NEXT: cmpwi 3, 1
60 ; PPC-NEXT: bclr 12, 2, 0
62 ; PPC-NEXT: ori 3, 5, 0
65 ; PPC64LE-LABEL: test_srem_even:
67 ; PPC64LE-NEXT: lis 4, 10922
68 ; PPC64LE-NEXT: slwi 3, 3, 28
69 ; PPC64LE-NEXT: ori 4, 4, 43691
70 ; PPC64LE-NEXT: srawi 3, 3, 28
71 ; PPC64LE-NEXT: mulhw 4, 3, 4
72 ; PPC64LE-NEXT: srwi 5, 4, 31
73 ; PPC64LE-NEXT: add 4, 4, 5
74 ; PPC64LE-NEXT: mulli 4, 4, 6
75 ; PPC64LE-NEXT: sub 3, 3, 4
76 ; PPC64LE-NEXT: li 4, 1
77 ; PPC64LE-NEXT: cmpwi 3, 1
78 ; PPC64LE-NEXT: li 3, 0
79 ; PPC64LE-NEXT: iseleq 3, 4, 3
82 %cmp = icmp eq i4 %srem, 1
86 define i1 @test_srem_pow2_setne(i6 %X) nounwind {
87 ; PPC-LABEL: test_srem_pow2_setne:
89 ; PPC-NEXT: slwi 4, 3, 26
90 ; PPC-NEXT: srawi 4, 4, 26
91 ; PPC-NEXT: rlwinm 4, 4, 23, 30, 31
92 ; PPC-NEXT: add 4, 3, 4
93 ; PPC-NEXT: rlwinm 4, 4, 0, 26, 29
94 ; PPC-NEXT: sub 3, 3, 4
95 ; PPC-NEXT: clrlwi 3, 3, 26
96 ; PPC-NEXT: cntlzw 3, 3
98 ; PPC-NEXT: rlwinm 3, 3, 27, 31, 31
101 ; PPC64LE-LABEL: test_srem_pow2_setne:
103 ; PPC64LE-NEXT: slwi 4, 3, 26
104 ; PPC64LE-NEXT: srawi 4, 4, 26
105 ; PPC64LE-NEXT: rlwinm 4, 4, 23, 30, 31
106 ; PPC64LE-NEXT: add 4, 3, 4
107 ; PPC64LE-NEXT: rlwinm 4, 4, 0, 26, 29
108 ; PPC64LE-NEXT: sub 3, 3, 4
109 ; PPC64LE-NEXT: clrlwi 3, 3, 26
110 ; PPC64LE-NEXT: cntlzw 3, 3
111 ; PPC64LE-NEXT: not 3, 3
112 ; PPC64LE-NEXT: rlwinm 3, 3, 27, 31, 31
114 %srem = srem i6 %X, 4
115 %cmp = icmp ne i6 %srem, 0
119 define <3 x i1> @test_srem_vec(<3 x i33> %X) nounwind {
120 ; PPC-LABEL: test_srem_vec:
123 ; PPC-NEXT: stw 0, 4(1)
124 ; PPC-NEXT: stwu 1, -48(1)
125 ; PPC-NEXT: stw 29, 36(1) # 4-byte Folded Spill
127 ; PPC-NEXT: clrlwi 5, 5, 31
128 ; PPC-NEXT: clrlwi 6, 7, 31
129 ; PPC-NEXT: clrlwi 3, 3, 31
130 ; PPC-NEXT: stw 27, 28(1) # 4-byte Folded Spill
131 ; PPC-NEXT: neg 27, 6
132 ; PPC-NEXT: stw 28, 32(1) # 4-byte Folded Spill
133 ; PPC-NEXT: neg 28, 5
137 ; PPC-NEXT: stw 25, 20(1) # 4-byte Folded Spill
138 ; PPC-NEXT: stw 26, 24(1) # 4-byte Folded Spill
139 ; PPC-NEXT: stw 30, 40(1) # 4-byte Folded Spill
141 ; PPC-NEXT: bl __moddi3
148 ; PPC-NEXT: bl __moddi3
155 ; PPC-NEXT: bl __moddi3
157 ; PPC-NEXT: xori 4, 4, 65533
158 ; PPC-NEXT: xori 5, 27, 3
159 ; PPC-NEXT: xori 6, 25, 3
160 ; PPC-NEXT: clrlwi 3, 3, 31
161 ; PPC-NEXT: xoris 4, 4, 65535
162 ; PPC-NEXT: or 5, 5, 30
163 ; PPC-NEXT: or 6, 6, 26
164 ; PPC-NEXT: or 4, 4, 3
165 ; PPC-NEXT: cntlzw 6, 6
166 ; PPC-NEXT: cntlzw 5, 5
167 ; PPC-NEXT: cntlzw 4, 4
171 ; PPC-NEXT: rlwinm 3, 3, 27, 31, 31
172 ; PPC-NEXT: rlwinm 5, 5, 27, 31, 31
173 ; PPC-NEXT: rlwinm 4, 4, 27, 31, 31
174 ; PPC-NEXT: lwz 30, 40(1) # 4-byte Folded Reload
175 ; PPC-NEXT: lwz 29, 36(1) # 4-byte Folded Reload
176 ; PPC-NEXT: lwz 28, 32(1) # 4-byte Folded Reload
177 ; PPC-NEXT: lwz 27, 28(1) # 4-byte Folded Reload
178 ; PPC-NEXT: lwz 26, 24(1) # 4-byte Folded Reload
179 ; PPC-NEXT: lwz 25, 20(1) # 4-byte Folded Reload
180 ; PPC-NEXT: lwz 0, 52(1)
181 ; PPC-NEXT: addi 1, 1, 48
185 ; PPC64LE-LABEL: test_srem_vec:
187 ; PPC64LE-NEXT: lis 6, 1820
188 ; PPC64LE-NEXT: sldi 3, 3, 31
189 ; PPC64LE-NEXT: ori 6, 6, 29127
190 ; PPC64LE-NEXT: sldi 5, 5, 31
191 ; PPC64LE-NEXT: rldic 6, 6, 34, 3
192 ; PPC64LE-NEXT: sldi 4, 4, 31
193 ; PPC64LE-NEXT: oris 6, 6, 29127
194 ; PPC64LE-NEXT: sradi 3, 3, 31
195 ; PPC64LE-NEXT: ori 7, 6, 7282
196 ; PPC64LE-NEXT: sradi 5, 5, 31
197 ; PPC64LE-NEXT: ori 6, 6, 7281
198 ; PPC64LE-NEXT: sradi 4, 4, 31
199 ; PPC64LE-NEXT: mulhd 8, 3, 7
200 ; PPC64LE-NEXT: mulhd 7, 4, 7
201 ; PPC64LE-NEXT: mulhd 6, 5, 6
202 ; PPC64LE-NEXT: rldicl 9, 8, 1, 63
203 ; PPC64LE-NEXT: rldicl 10, 7, 1, 63
204 ; PPC64LE-NEXT: sub 6, 6, 5
205 ; PPC64LE-NEXT: add 8, 8, 9
206 ; PPC64LE-NEXT: rldicl 9, 6, 1, 63
207 ; PPC64LE-NEXT: add 7, 7, 10
208 ; PPC64LE-NEXT: sradi 6, 6, 3
209 ; PPC64LE-NEXT: sldi 10, 8, 3
210 ; PPC64LE-NEXT: add 6, 6, 9
211 ; PPC64LE-NEXT: add 8, 8, 10
212 ; PPC64LE-NEXT: addis 9, 2, .LCPI3_0@toc@ha
213 ; PPC64LE-NEXT: sldi 10, 7, 3
214 ; PPC64LE-NEXT: sub 3, 3, 8
215 ; PPC64LE-NEXT: addi 9, 9, .LCPI3_0@toc@l
216 ; PPC64LE-NEXT: add 7, 7, 10
217 ; PPC64LE-NEXT: sldi 8, 6, 3
218 ; PPC64LE-NEXT: lxvd2x 0, 0, 9
219 ; PPC64LE-NEXT: mtfprd 1, 3
220 ; PPC64LE-NEXT: sub 4, 4, 7
221 ; PPC64LE-NEXT: add 6, 6, 8
222 ; PPC64LE-NEXT: addis 7, 2, .LCPI3_1@toc@ha
223 ; PPC64LE-NEXT: mtfprd 2, 4
224 ; PPC64LE-NEXT: add 4, 5, 6
225 ; PPC64LE-NEXT: addi 3, 7, .LCPI3_1@toc@l
226 ; PPC64LE-NEXT: addis 5, 2, .LCPI3_2@toc@ha
227 ; PPC64LE-NEXT: mtfprd 4, 4
228 ; PPC64LE-NEXT: lxvd2x 3, 0, 3
229 ; PPC64LE-NEXT: addi 3, 5, .LCPI3_2@toc@l
230 ; PPC64LE-NEXT: xxswapd 34, 0
231 ; PPC64LE-NEXT: xxmrghd 35, 2, 1
232 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
233 ; PPC64LE-NEXT: xxswapd 36, 4
234 ; PPC64LE-NEXT: xxswapd 37, 3
235 ; PPC64LE-NEXT: xxland 35, 35, 34
236 ; PPC64LE-NEXT: xxland 34, 36, 34
237 ; PPC64LE-NEXT: xxswapd 36, 0
238 ; PPC64LE-NEXT: vcmpequd 3, 3, 5
239 ; PPC64LE-NEXT: vcmpequd 2, 2, 4
240 ; PPC64LE-NEXT: xxlnor 0, 35, 35
241 ; PPC64LE-NEXT: xxlnor 34, 34, 34
242 ; PPC64LE-NEXT: xxswapd 1, 0
243 ; PPC64LE-NEXT: mffprwz 4, 0
244 ; PPC64LE-NEXT: xxswapd 2, 34
245 ; PPC64LE-NEXT: mffprwz 3, 1
246 ; PPC64LE-NEXT: mffprwz 5, 2
248 %srem = srem <3 x i33> %X, <i33 9, i33 9, i33 -9>
249 %cmp = icmp ne <3 x i33> %srem, <i33 3, i33 -3, i33 3>