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: clrlwi 3, 3, 3
15 ; PPC-NEXT: ori 4, 4, 48987
16 ; PPC-NEXT: cmplw 3, 4
18 ; PPC-NEXT: bclr 12, 0, 0
23 ; PPC64LE-LABEL: test_srem_odd:
25 ; PPC64LE-NEXT: lis 4, 8026
26 ; PPC64LE-NEXT: ori 4, 4, 33099
27 ; PPC64LE-NEXT: mullw 3, 3, 4
28 ; PPC64LE-NEXT: lis 4, 82
29 ; PPC64LE-NEXT: ori 4, 4, 48987
30 ; PPC64LE-NEXT: addi 3, 3, 24493
31 ; PPC64LE-NEXT: addis 3, 3, 41
32 ; PPC64LE-NEXT: clrlwi 3, 3, 3
33 ; PPC64LE-NEXT: cmplw 3, 4
34 ; PPC64LE-NEXT: li 3, 0
35 ; PPC64LE-NEXT: li 4, 1
36 ; PPC64LE-NEXT: isellt 3, 4, 3
38 %srem = srem i29 %X, 99
39 %cmp = icmp eq i29 %srem, 0
43 define i1 @test_srem_even(i4 %X) nounwind {
44 ; PPC-LABEL: test_srem_even:
46 ; PPC-NEXT: slwi 4, 3, 28
47 ; PPC-NEXT: srawi 4, 4, 28
48 ; PPC-NEXT: mulli 4, 4, 3
49 ; PPC-NEXT: srwi 5, 4, 31
50 ; PPC-NEXT: srwi 4, 4, 4
51 ; PPC-NEXT: add 4, 4, 5
52 ; PPC-NEXT: mulli 4, 4, 6
53 ; PPC-NEXT: sub 3, 3, 4
54 ; PPC-NEXT: clrlwi 3, 3, 28
55 ; PPC-NEXT: cmpwi 3, 1
57 ; PPC-NEXT: bclr 12, 2, 0
62 ; PPC64LE-LABEL: test_srem_even:
64 ; PPC64LE-NEXT: slwi 4, 3, 28
65 ; PPC64LE-NEXT: srawi 4, 4, 28
66 ; PPC64LE-NEXT: slwi 5, 4, 1
67 ; PPC64LE-NEXT: add 4, 4, 5
68 ; PPC64LE-NEXT: srwi 5, 4, 31
69 ; PPC64LE-NEXT: srwi 4, 4, 4
70 ; PPC64LE-NEXT: add 4, 4, 5
71 ; PPC64LE-NEXT: mulli 4, 4, 6
72 ; PPC64LE-NEXT: sub 3, 3, 4
73 ; PPC64LE-NEXT: li 4, 1
74 ; PPC64LE-NEXT: clrlwi 3, 3, 28
75 ; PPC64LE-NEXT: cmpwi 3, 1
76 ; PPC64LE-NEXT: li 3, 0
77 ; PPC64LE-NEXT: iseleq 3, 4, 3
80 %cmp = icmp eq i4 %srem, 1
84 define i1 @test_srem_pow2_setne(i6 %X) nounwind {
85 ; PPC-LABEL: test_srem_pow2_setne:
87 ; PPC-NEXT: slwi 4, 3, 26
88 ; PPC-NEXT: srawi 4, 4, 31
89 ; PPC-NEXT: clrlwi 4, 4, 30
90 ; PPC-NEXT: add 4, 3, 4
91 ; PPC-NEXT: rlwinm 4, 4, 0, 26, 29
92 ; PPC-NEXT: sub 3, 3, 4
93 ; PPC-NEXT: clrlwi 3, 3, 26
94 ; PPC-NEXT: cntlzw 3, 3
96 ; PPC-NEXT: rlwinm 3, 3, 27, 31, 31
99 ; PPC64LE-LABEL: test_srem_pow2_setne:
101 ; PPC64LE-NEXT: slwi 4, 3, 26
102 ; PPC64LE-NEXT: srawi 4, 4, 31
103 ; PPC64LE-NEXT: clrlwi 4, 4, 30
104 ; PPC64LE-NEXT: add 4, 3, 4
105 ; PPC64LE-NEXT: rlwinm 4, 4, 0, 26, 29
106 ; PPC64LE-NEXT: sub 3, 3, 4
107 ; PPC64LE-NEXT: clrlwi 3, 3, 26
108 ; PPC64LE-NEXT: cntlzw 3, 3
109 ; PPC64LE-NEXT: not 3, 3
110 ; PPC64LE-NEXT: rlwinm 3, 3, 27, 31, 31
112 %srem = srem i6 %X, 4
113 %cmp = icmp ne i6 %srem, 0
117 define <3 x i1> @test_srem_vec(<3 x i33> %X) nounwind {
118 ; PPC-LABEL: test_srem_vec:
121 ; PPC-NEXT: stwu 1, -48(1)
122 ; PPC-NEXT: stw 0, 52(1)
123 ; PPC-NEXT: clrlwi 5, 5, 31
124 ; PPC-NEXT: stw 29, 36(1) # 4-byte Folded Spill
126 ; PPC-NEXT: clrlwi 6, 7, 31
127 ; PPC-NEXT: clrlwi 3, 3, 31
128 ; PPC-NEXT: stw 27, 28(1) # 4-byte Folded Spill
129 ; PPC-NEXT: neg 27, 6
130 ; PPC-NEXT: stw 28, 32(1) # 4-byte Folded Spill
131 ; PPC-NEXT: neg 28, 5
135 ; PPC-NEXT: stw 25, 20(1) # 4-byte Folded Spill
136 ; PPC-NEXT: stw 26, 24(1) # 4-byte Folded Spill
137 ; PPC-NEXT: stw 30, 40(1) # 4-byte Folded Spill
139 ; PPC-NEXT: bl __moddi3
146 ; PPC-NEXT: bl __moddi3
153 ; PPC-NEXT: bl __moddi3
155 ; PPC-NEXT: xori 4, 4, 65533
156 ; PPC-NEXT: xori 5, 27, 3
157 ; PPC-NEXT: xori 6, 25, 3
158 ; PPC-NEXT: clrlwi 3, 3, 31
159 ; PPC-NEXT: xoris 4, 4, 65535
160 ; PPC-NEXT: or 5, 5, 30
161 ; PPC-NEXT: or 6, 6, 26
162 ; PPC-NEXT: or 4, 4, 3
163 ; PPC-NEXT: cntlzw 6, 6
164 ; PPC-NEXT: cntlzw 5, 5
165 ; PPC-NEXT: cntlzw 4, 4
169 ; PPC-NEXT: rlwinm 3, 3, 27, 31, 31
170 ; PPC-NEXT: rlwinm 5, 5, 27, 31, 31
171 ; PPC-NEXT: rlwinm 4, 4, 27, 31, 31
172 ; PPC-NEXT: lwz 30, 40(1) # 4-byte Folded Reload
173 ; PPC-NEXT: lwz 29, 36(1) # 4-byte Folded Reload
174 ; PPC-NEXT: lwz 28, 32(1) # 4-byte Folded Reload
175 ; PPC-NEXT: lwz 27, 28(1) # 4-byte Folded Reload
176 ; PPC-NEXT: lwz 26, 24(1) # 4-byte Folded Reload
177 ; PPC-NEXT: lwz 25, 20(1) # 4-byte Folded Reload
178 ; PPC-NEXT: lwz 0, 52(1)
179 ; PPC-NEXT: addi 1, 1, 48
183 ; PPC64LE-LABEL: test_srem_vec:
185 ; PPC64LE-NEXT: lis 6, 1820
186 ; PPC64LE-NEXT: sldi 3, 3, 31
187 ; PPC64LE-NEXT: sldi 4, 4, 31
188 ; PPC64LE-NEXT: sldi 5, 5, 31
189 ; PPC64LE-NEXT: ori 6, 6, 29127
190 ; PPC64LE-NEXT: sradi 3, 3, 31
191 ; PPC64LE-NEXT: sradi 4, 4, 31
192 ; PPC64LE-NEXT: sradi 5, 5, 31
193 ; PPC64LE-NEXT: rldic 6, 6, 34, 3
194 ; PPC64LE-NEXT: oris 6, 6, 29127
195 ; PPC64LE-NEXT: ori 7, 6, 7282
196 ; PPC64LE-NEXT: mulhd 8, 3, 7
197 ; PPC64LE-NEXT: rldicl 9, 8, 1, 63
198 ; PPC64LE-NEXT: add 8, 8, 9
199 ; PPC64LE-NEXT: sldi 9, 8, 3
200 ; PPC64LE-NEXT: add 8, 8, 9
201 ; PPC64LE-NEXT: sub 3, 3, 8
202 ; PPC64LE-NEXT: mtfprd 0, 3
203 ; PPC64LE-NEXT: mulhd 3, 4, 7
204 ; PPC64LE-NEXT: rldicl 7, 3, 1, 63
205 ; PPC64LE-NEXT: add 3, 3, 7
206 ; PPC64LE-NEXT: sldi 7, 3, 3
207 ; PPC64LE-NEXT: add 3, 3, 7
208 ; PPC64LE-NEXT: sub 3, 4, 3
209 ; PPC64LE-NEXT: mtfprd 1, 3
210 ; PPC64LE-NEXT: ori 3, 6, 7281
211 ; PPC64LE-NEXT: mulhd 3, 5, 3
212 ; PPC64LE-NEXT: sub 3, 3, 5
213 ; PPC64LE-NEXT: rldicl 4, 3, 1, 63
214 ; PPC64LE-NEXT: sradi 3, 3, 3
215 ; PPC64LE-NEXT: add 3, 3, 4
216 ; PPC64LE-NEXT: sldi 4, 3, 3
217 ; PPC64LE-NEXT: add 3, 3, 4
218 ; PPC64LE-NEXT: add 3, 5, 3
219 ; PPC64LE-NEXT: xxmrghd 34, 1, 0
220 ; PPC64LE-NEXT: mtfprd 0, 3
221 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_1@toc@ha
222 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_1@toc@l
223 ; PPC64LE-NEXT: xxswapd 35, 0
224 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
225 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_2@toc@ha
226 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_2@toc@l
227 ; PPC64LE-NEXT: xxswapd 36, 0
228 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
229 ; PPC64LE-NEXT: addis 3, 2, .LCPI3_0@toc@ha
230 ; PPC64LE-NEXT: addi 3, 3, .LCPI3_0@toc@l
231 ; PPC64LE-NEXT: xxswapd 37, 0
232 ; PPC64LE-NEXT: lxvd2x 0, 0, 3
233 ; PPC64LE-NEXT: xxland 34, 34, 0
234 ; PPC64LE-NEXT: xxland 35, 35, 0
235 ; PPC64LE-NEXT: vcmpequd 2, 2, 4
236 ; PPC64LE-NEXT: xxlnor 0, 34, 34
237 ; PPC64LE-NEXT: vcmpequd 2, 3, 5
238 ; PPC64LE-NEXT: xxlnor 34, 34, 34
239 ; PPC64LE-NEXT: mffprwz 4, 0
240 ; PPC64LE-NEXT: xxswapd 1, 0
241 ; PPC64LE-NEXT: mffprwz 3, 1
242 ; PPC64LE-NEXT: xxswapd 2, 34
243 ; PPC64LE-NEXT: mffprwz 5, 2
245 %srem = srem <3 x i33> %X, <i33 9, i33 9, i33 -9>
246 %cmp = icmp ne <3 x i33> %srem, <i33 3, i33 -3, i33 3>