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 4, 3, 28
68 ; PPC64LE-NEXT: srawi 4, 4, 28
69 ; PPC64LE-NEXT: slwi 5, 4, 1
70 ; PPC64LE-NEXT: add 4, 4, 5
71 ; PPC64LE-NEXT: rlwinm 5, 4, 25, 31, 31
72 ; PPC64LE-NEXT: srwi 4, 4, 4
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: clrlwi 3, 3, 28
78 ; PPC64LE-NEXT: cmpwi 3, 1
79 ; PPC64LE-NEXT: li 3, 0
80 ; PPC64LE-NEXT: iseleq 3, 4, 3
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: sldi 4, 4, 31
191 ; PPC64LE-NEXT: sldi 5, 5, 31
192 ; PPC64LE-NEXT: ori 6, 6, 29127
193 ; PPC64LE-NEXT: sradi 3, 3, 31
194 ; PPC64LE-NEXT: sradi 4, 4, 31
195 ; PPC64LE-NEXT: sradi 5, 5, 31
196 ; PPC64LE-NEXT: rldic 6, 6, 34, 3
197 ; PPC64LE-NEXT: oris 6, 6, 29127
198 ; PPC64LE-NEXT: ori 7, 6, 7282
199 ; PPC64LE-NEXT: mulhd 8, 3, 7
200 ; PPC64LE-NEXT: rldicl 9, 8, 1, 63
201 ; PPC64LE-NEXT: add 8, 8, 9
202 ; PPC64LE-NEXT: sldi 9, 8, 3
203 ; PPC64LE-NEXT: add 8, 8, 9
204 ; PPC64LE-NEXT: sub 3, 3, 8
205 ; PPC64LE-NEXT: mtfprd 0, 3
206 ; PPC64LE-NEXT: mulhd 3, 4, 7
207 ; PPC64LE-NEXT: rldicl 7, 3, 1, 63
208 ; PPC64LE-NEXT: add 3, 3, 7
209 ; PPC64LE-NEXT: sldi 7, 3, 3
210 ; PPC64LE-NEXT: add 3, 3, 7
211 ; PPC64LE-NEXT: sub 3, 4, 3
212 ; PPC64LE-NEXT: mtfprd 1, 3
213 ; PPC64LE-NEXT: ori 3, 6, 7281
214 ; PPC64LE-NEXT: mulhd 3, 5, 3
215 ; PPC64LE-NEXT: sub 3, 3, 5
216 ; PPC64LE-NEXT: rldicl 4, 3, 1, 63
217 ; PPC64LE-NEXT: sradi 3, 3, 3
218 ; PPC64LE-NEXT: add 3, 3, 4
219 ; PPC64LE-NEXT: sldi 4, 3, 3
220 ; PPC64LE-NEXT: add 3, 3, 4
221 ; PPC64LE-NEXT: add 3, 5, 3
222 ; PPC64LE-NEXT: xxmrghd 34, 1, 0
223 ; PPC64LE-NEXT: mtfprd 0, 3
224 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_1@toc@ha
225 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_1@toc@l
226 ; PPC64LE-NEXT: xxswapd 35, 0
227 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
228 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_2@toc@ha
229 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_2@toc@l
230 ; PPC64LE-NEXT: xxswapd 36, 0
231 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
232 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_0@toc@ha
233 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_0@toc@l
234 ; PPC64LE-NEXT: xxswapd 37, 0
235 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
236 ; PPC64LE-NEXT: xxland 34, 34, 0
237 ; PPC64LE-NEXT: xxland 35, 35, 0
238 ; PPC64LE-NEXT: vcmpequd 2, 2, 4
239 ; PPC64LE-NEXT: xxlnor 0, 34, 34
240 ; PPC64LE-NEXT: vcmpequd 2, 3, 5
241 ; PPC64LE-NEXT: xxlnor 34, 34, 34
242 ; PPC64LE-NEXT: mffprwz 4, 0
243 ; PPC64LE-NEXT: xxswapd 1, 0
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>