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: slwi 5, 3, 28
49 ; PPC-NEXT: srawi 5, 5, 28
50 ; PPC-NEXT: mulli 5, 5, 3
51 ; PPC-NEXT: rlwinm 6, 5, 25, 31, 31
52 ; PPC-NEXT: srwi 5, 5, 4
53 ; PPC-NEXT: add 5, 5, 6
54 ; PPC-NEXT: mulli 5, 5, 6
55 ; PPC-NEXT: sub 3, 3, 5
56 ; PPC-NEXT: clrlwi 3, 3, 28
58 ; PPC-NEXT: cmpwi 3, 1
60 ; PPC-NEXT: bclr 12, 2, 0
62 ; PPC-NEXT: ori 3, 4, 0
65 ; PPC64LE-LABEL: test_srem_even:
67 ; PPC64LE-NEXT: slwi 5, 3, 28
68 ; PPC64LE-NEXT: li 4, 0
69 ; PPC64LE-NEXT: srawi 5, 5, 28
70 ; PPC64LE-NEXT: slwi 6, 5, 1
71 ; PPC64LE-NEXT: add 5, 5, 6
72 ; PPC64LE-NEXT: rlwinm 6, 5, 25, 31, 31
73 ; PPC64LE-NEXT: srwi 5, 5, 4
74 ; PPC64LE-NEXT: add 5, 5, 6
75 ; PPC64LE-NEXT: mulli 5, 5, 6
76 ; PPC64LE-NEXT: sub 3, 3, 5
77 ; PPC64LE-NEXT: clrlwi 3, 3, 28
78 ; PPC64LE-NEXT: cmpwi 3, 1
79 ; PPC64LE-NEXT: li 3, 1
80 ; PPC64LE-NEXT: iseleq 3, 3, 4
83 %cmp = icmp eq i4 %srem, 1
87 define i1 @test_srem_pow2_setne(i6 %X) nounwind {
88 ; PPC-LABEL: test_srem_pow2_setne:
90 ; PPC-NEXT: slwi 4, 3, 26
91 ; PPC-NEXT: srawi 4, 4, 26
92 ; PPC-NEXT: rlwinm 4, 4, 23, 30, 31
93 ; PPC-NEXT: add 4, 3, 4
94 ; PPC-NEXT: rlwinm 4, 4, 0, 26, 29
95 ; PPC-NEXT: sub 3, 3, 4
96 ; PPC-NEXT: clrlwi 3, 3, 26
97 ; PPC-NEXT: cntlzw 3, 3
99 ; PPC-NEXT: rlwinm 3, 3, 27, 31, 31
102 ; PPC64LE-LABEL: test_srem_pow2_setne:
104 ; PPC64LE-NEXT: slwi 4, 3, 26
105 ; PPC64LE-NEXT: srawi 4, 4, 26
106 ; PPC64LE-NEXT: rlwinm 4, 4, 23, 30, 31
107 ; PPC64LE-NEXT: add 4, 3, 4
108 ; PPC64LE-NEXT: rlwinm 4, 4, 0, 26, 29
109 ; PPC64LE-NEXT: sub 3, 3, 4
110 ; PPC64LE-NEXT: clrlwi 3, 3, 26
111 ; PPC64LE-NEXT: cntlzw 3, 3
112 ; PPC64LE-NEXT: not 3, 3
113 ; PPC64LE-NEXT: rlwinm 3, 3, 27, 31, 31
115 %srem = srem i6 %X, 4
116 %cmp = icmp ne i6 %srem, 0
120 define <3 x i1> @test_srem_vec(<3 x i33> %X) nounwind {
121 ; PPC-LABEL: test_srem_vec:
124 ; PPC-NEXT: stwu 1, -48(1)
125 ; PPC-NEXT: stw 0, 52(1)
126 ; PPC-NEXT: clrlwi 5, 5, 31
127 ; PPC-NEXT: stw 29, 36(1) # 4-byte Folded Spill
129 ; PPC-NEXT: clrlwi 6, 7, 31
130 ; PPC-NEXT: clrlwi 3, 3, 31
131 ; PPC-NEXT: stw 27, 28(1) # 4-byte Folded Spill
132 ; PPC-NEXT: neg 27, 6
133 ; PPC-NEXT: stw 28, 32(1) # 4-byte Folded Spill
134 ; PPC-NEXT: neg 28, 5
138 ; PPC-NEXT: stw 25, 20(1) # 4-byte Folded Spill
139 ; PPC-NEXT: stw 26, 24(1) # 4-byte Folded Spill
140 ; PPC-NEXT: stw 30, 40(1) # 4-byte Folded Spill
142 ; PPC-NEXT: bl __moddi3
149 ; PPC-NEXT: bl __moddi3
156 ; PPC-NEXT: bl __moddi3
158 ; PPC-NEXT: xori 4, 4, 65533
159 ; PPC-NEXT: xori 5, 27, 3
160 ; PPC-NEXT: xori 6, 25, 3
161 ; PPC-NEXT: clrlwi 3, 3, 31
162 ; PPC-NEXT: xoris 4, 4, 65535
163 ; PPC-NEXT: or 5, 5, 30
164 ; PPC-NEXT: or 6, 6, 26
165 ; PPC-NEXT: or 4, 4, 3
166 ; PPC-NEXT: cntlzw 6, 6
167 ; PPC-NEXT: cntlzw 5, 5
168 ; PPC-NEXT: cntlzw 4, 4
172 ; PPC-NEXT: rlwinm 3, 3, 27, 31, 31
173 ; PPC-NEXT: rlwinm 5, 5, 27, 31, 31
174 ; PPC-NEXT: rlwinm 4, 4, 27, 31, 31
175 ; PPC-NEXT: lwz 30, 40(1) # 4-byte Folded Reload
176 ; PPC-NEXT: lwz 29, 36(1) # 4-byte Folded Reload
177 ; PPC-NEXT: lwz 28, 32(1) # 4-byte Folded Reload
178 ; PPC-NEXT: lwz 27, 28(1) # 4-byte Folded Reload
179 ; PPC-NEXT: lwz 26, 24(1) # 4-byte Folded Reload
180 ; PPC-NEXT: lwz 25, 20(1) # 4-byte Folded Reload
181 ; PPC-NEXT: lwz 0, 52(1)
182 ; PPC-NEXT: addi 1, 1, 48
186 ; PPC64LE-LABEL: test_srem_vec:
188 ; PPC64LE-NEXT: lis 6, 1820
189 ; PPC64LE-NEXT: sldi 3, 3, 31
190 ; PPC64LE-NEXT: ori 6, 6, 29127
191 ; PPC64LE-NEXT: sldi 4, 4, 31
192 ; PPC64LE-NEXT: rldic 6, 6, 34, 3
193 ; PPC64LE-NEXT: sradi 3, 3, 31
194 ; PPC64LE-NEXT: oris 6, 6, 29127
195 ; PPC64LE-NEXT: sradi 4, 4, 31
196 ; PPC64LE-NEXT: ori 7, 6, 7282
197 ; PPC64LE-NEXT: sldi 5, 5, 31
198 ; PPC64LE-NEXT: ori 6, 6, 7281
199 ; PPC64LE-NEXT: mulhd 8, 3, 7
200 ; PPC64LE-NEXT: mulhd 7, 4, 7
201 ; PPC64LE-NEXT: sradi 5, 5, 31
202 ; PPC64LE-NEXT: mulhd 6, 5, 6
203 ; PPC64LE-NEXT: rldicl 9, 8, 1, 63
204 ; PPC64LE-NEXT: rldicl 10, 7, 1, 63
205 ; PPC64LE-NEXT: add 8, 8, 9
206 ; PPC64LE-NEXT: add 7, 7, 10
207 ; PPC64LE-NEXT: sldi 10, 8, 3
208 ; PPC64LE-NEXT: sub 6, 6, 5
209 ; PPC64LE-NEXT: add 8, 8, 10
210 ; PPC64LE-NEXT: sldi 10, 7, 3
211 ; PPC64LE-NEXT: rldicl 9, 6, 1, 63
212 ; PPC64LE-NEXT: add 7, 7, 10
213 ; PPC64LE-NEXT: sub 3, 3, 8
214 ; PPC64LE-NEXT: addis 8, 2, .LCPI3_1@toc@ha
215 ; PPC64LE-NEXT: sradi 6, 6, 3
216 ; PPC64LE-NEXT: sub 4, 4, 7
217 ; PPC64LE-NEXT: mtfprd 0, 3
218 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_0@toc@ha
219 ; PPC64LE-NEXT: addi 7, 8, .LCPI3_1@toc@l
220 ; PPC64LE-NEXT: add 6, 6, 9
221 ; PPC64LE-NEXT: mtfprd 1, 4
222 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_0@toc@l
223 ; PPC64LE-NEXT: lxvd2x 2, 0, 7
224 ; PPC64LE-NEXT: sldi 8, 6, 3
225 ; PPC64LE-NEXT: lxvd2x 3, 0, 3
226 ; PPC64LE-NEXT: add 4, 6, 8
227 ; PPC64LE-NEXT: addis 6, 2, .LCPI3_2@toc@ha
228 ; PPC64LE-NEXT: xxmrghd 34, 1, 0
229 ; PPC64LE-NEXT: add 3, 5, 4
230 ; PPC64LE-NEXT: addi 4, 6, .LCPI3_2@toc@l
231 ; PPC64LE-NEXT: xxswapd 35, 2
232 ; PPC64LE-NEXT: mtfprd 0, 3
233 ; PPC64LE-NEXT: lxvd2x 1, 0, 4
234 ; PPC64LE-NEXT: xxland 34, 34, 3
235 ; PPC64LE-NEXT: xxswapd 36, 0
236 ; PPC64LE-NEXT: vcmpequd 2, 2, 3
237 ; PPC64LE-NEXT: xxswapd 35, 1
238 ; PPC64LE-NEXT: xxland 36, 36, 3
239 ; PPC64LE-NEXT: vcmpequd 3, 4, 3
240 ; PPC64LE-NEXT: xxlnor 0, 34, 34
241 ; PPC64LE-NEXT: xxswapd 1, 0
242 ; PPC64LE-NEXT: mffprwz 4, 0
243 ; PPC64LE-NEXT: xxlnor 34, 35, 35
244 ; PPC64LE-NEXT: mffprwz 3, 1
245 ; PPC64LE-NEXT: xxswapd 2, 34
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>