Debian Codegraph @

llvm/test/CodeGen/Thumb2/mve-complex-deinterleaving-mixed-cases.ll

raw
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s --mattr=+mve.fp,+fp64 -o - | FileCheck %s
3
4 target triple = "thumbv8.1m.main-none-none-eabi"
5
6 ; Expected to transform
7 define arm_aapcs_vfpcc <4 x float> @mul_mul(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
8 ; CHECK-LABEL: mul_mul:
9 ; CHECK: @ %bb.0: @ %entry
10 ; CHECK-NEXT: vcmul.f32 q3, q0, q1, #0
11 ; CHECK-NEXT: vcmla.f32 q3, q0, q1, #90
12 ; CHECK-NEXT: vcmul.f32 q0, q3, q2, #0
13 ; CHECK-NEXT: vcmla.f32 q0, q3, q2, #90
14 ; CHECK-NEXT: bx lr
15 entry:
16 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
17 %strided.vec151 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
18 %strided.vec153 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
19 %strided.vec154 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
20 %0 = fmul fast <2 x float> %strided.vec154, %strided.vec151
21 %1 = fmul fast <2 x float> %strided.vec153, %strided.vec
22 %2 = fmul fast <2 x float> %strided.vec154, %strided.vec
23 %3 = fmul fast <2 x float> %strided.vec153, %strided.vec151
24 %4 = fadd fast <2 x float> %3, %2
25 %5 = fsub fast <2 x float> %1, %0
26 %strided.vec156 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
27 %strided.vec157 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
28 %6 = fmul fast <2 x float> %4, %strided.vec156
29 %7 = fmul fast <2 x float> %5, %strided.vec157
30 %8 = fadd fast <2 x float> %6, %7
31 %9 = fmul fast <2 x float> %strided.vec156, %5
32 %10 = fmul fast <2 x float> %4, %strided.vec157
33 %11 = fsub fast <2 x float> %9, %10
34 %interleaved.vec = shufflevector <2 x float> %11, <2 x float> %8, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
35 ret <4 x float> %interleaved.vec
36 }
37
38 ; Expected to not transform
39 define arm_aapcs_vfpcc <4 x float> @add_mul(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
40 ; CHECK-LABEL: add_mul:
41 ; CHECK: @ %bb.0: @ %entry
42 ; CHECK-NEXT: .vsave {d8, d9}
43 ; CHECK-NEXT: vpush {d8, d9}
44 ; CHECK-NEXT: vsub.f32 q3, q1, q2
45 ; CHECK-NEXT: vsub.f32 q0, q1, q0
46 ; CHECK-NEXT: vmov.f32 s4, s9
47 ; CHECK-NEXT: vmov.f32 s13, s14
48 ; CHECK-NEXT: vmov.f32 s5, s11
49 ; CHECK-NEXT: vmov.f32 s0, s1
50 ; CHECK-NEXT: vmul.f32 q4, q3, q1
51 ; CHECK-NEXT: vmov.f32 s1, s3
52 ; CHECK-NEXT: vmov.f32 s9, s10
53 ; CHECK-NEXT: vfma.f32 q4, q2, q0
54 ; CHECK-NEXT: vmul.f32 q0, q1, q0
55 ; CHECK-NEXT: vneg.f32 q1, q0
56 ; CHECK-NEXT: vmov.f32 s1, s16
57 ; CHECK-NEXT: vfma.f32 q1, q2, q3
58 ; CHECK-NEXT: vmov.f32 s3, s17
59 ; CHECK-NEXT: vmov.f32 s0, s4
60 ; CHECK-NEXT: vmov.f32 s2, s5
61 ; CHECK-NEXT: vpop {d8, d9}
62 ; CHECK-NEXT: bx lr
63 entry:
64 %0 = fsub fast <4 x float> %b, %c
65 %1 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 2>
66 %strided.vec58 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
67 %strided.vec59 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
68 %2 = fmul fast <2 x float> %1, %strided.vec59
69 %3 = fsub fast <4 x float> %b, %a
70 %4 = shufflevector <4 x float> %3, <4 x float> poison, <2 x i32> <i32 1, i32 3>
71 %5 = fmul fast <2 x float> %strided.vec58, %4
72 %6 = fadd fast <2 x float> %5, %2
73 %7 = fmul fast <2 x float> %strided.vec58, %1
74 %8 = fmul fast <2 x float> %strided.vec59, %4
75 %9 = fsub fast <2 x float> %7, %8
76 %interleaved.vec = shufflevector <2 x float> %9, <2 x float> %6, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
77 ret <4 x float> %interleaved.vec
78 }
79
80 ; Expected to not transform
81 define arm_aapcs_vfpcc <4 x float> @mul_mul270_mul(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
82 ; CHECK-LABEL: mul_mul270_mul:
83 ; CHECK: @ %bb.0: @ %entry
84 ; CHECK-NEXT: .vsave {d8, d9, d10}
85 ; CHECK-NEXT: vpush {d8, d9, d10}
86 ; CHECK-NEXT: vmov.f32 s16, s8
87 ; CHECK-NEXT: vmov.f32 s20, s4
88 ; CHECK-NEXT: vmov.f32 s17, s10
89 ; CHECK-NEXT: vmov.f32 s21, s6
90 ; CHECK-NEXT: vmul.f32 q3, q5, q4
91 ; CHECK-NEXT: vmov.f32 s4, s5
92 ; CHECK-NEXT: vmov.f32 s5, s7
93 ; CHECK-NEXT: vneg.f32 q3, q3
94 ; CHECK-NEXT: vmov.f32 s8, s9
95 ; CHECK-NEXT: vmul.f32 q4, q1, q4
96 ; CHECK-NEXT: vmov.f32 s9, s11
97 ; CHECK-NEXT: vfma.f32 q3, q1, q2
98 ; CHECK-NEXT: vfma.f32 q4, q5, q2
99 ; CHECK-NEXT: vmov.f32 s8, s0
100 ; CHECK-NEXT: vmov.f32 s9, s2
101 ; CHECK-NEXT: vmov.f32 s0, s1
102 ; CHECK-NEXT: vmul.f32 q1, q3, q2
103 ; CHECK-NEXT: vmov.f32 s1, s3
104 ; CHECK-NEXT: vfma.f32 q1, q4, q0
105 ; CHECK-NEXT: vmul.f32 q0, q3, q0
106 ; CHECK-NEXT: vneg.f32 q3, q0
107 ; CHECK-NEXT: vmov.f32 s1, s4
108 ; CHECK-NEXT: vfma.f32 q3, q4, q2
109 ; CHECK-NEXT: vmov.f32 s3, s5
110 ; CHECK-NEXT: vmov.f32 s0, s12
111 ; CHECK-NEXT: vmov.f32 s2, s13
112 ; CHECK-NEXT: vpop {d8, d9, d10}
113 ; CHECK-NEXT: bx lr
114 entry:
115 %strided.vec = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
116 %strided.vec81 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
117 %strided.vec83 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
118 %strided.vec84 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
119 %0 = fmul fast <2 x float> %strided.vec84, %strided.vec
120 %1 = fmul fast <2 x float> %strided.vec83, %strided.vec81
121 %2 = fadd fast <2 x float> %1, %0
122 %strided.vec86 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
123 %strided.vec87 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
124 %3 = fmul fast <2 x float> %2, %strided.vec87
125 %4 = fmul fast <2 x float> %strided.vec84, %strided.vec81
126 %5 = fmul fast <2 x float> %strided.vec83, %strided.vec
127 %6 = fsub fast <2 x float> %4, %5
128 %7 = fmul fast <2 x float> %6, %strided.vec86
129 %8 = fadd fast <2 x float> %3, %7
130 %9 = fmul fast <2 x float> %2, %strided.vec86
131 %10 = fmul fast <2 x float> %6, %strided.vec87
132 %11 = fsub fast <2 x float> %9, %10
133 %interleaved.vec = shufflevector <2 x float> %11, <2 x float> %8, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
134 ret <4 x float> %interleaved.vec
135 }
136
137 ; (a * b) * a
138 ; Expected to transform
139 define arm_aapcs_vfpcc <4 x float> @mul_triangle(<4 x float> %a, <4 x float> %b) {
140 ; CHECK-LABEL: mul_triangle:
141 ; CHECK: @ %bb.0: @ %entry
142 ; CHECK-NEXT: vcmul.f32 q2, q1, q0, #0
143 ; CHECK-NEXT: vcmla.f32 q2, q1, q0, #90
144 ; CHECK-NEXT: vcmul.f32 q1, q0, q2, #0
145 ; CHECK-NEXT: vcmla.f32 q1, q0, q2, #90
146 ; CHECK-NEXT: vmov q0, q1
147 ; CHECK-NEXT: bx lr
148 entry:
149 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
150 %strided.vec35 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
151 %strided.vec37 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
152 %strided.vec38 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
153 %0 = fmul fast <2 x float> %strided.vec37, %strided.vec
154 %1 = fmul fast <2 x float> %strided.vec38, %strided.vec35
155 %2 = fsub fast <2 x float> %0, %1
156 %3 = fmul fast <2 x float> %2, %strided.vec35
157 %4 = fmul fast <2 x float> %strided.vec38, %strided.vec
158 %5 = fmul fast <2 x float> %strided.vec35, %strided.vec37
159 %6 = fadd fast <2 x float> %4, %5
160 %7 = fmul fast <2 x float> %6, %strided.vec
161 %8 = fadd fast <2 x float> %3, %7
162 %9 = fmul fast <2 x float> %2, %strided.vec
163 %10 = fmul fast <2 x float> %6, %strided.vec35
164 %11 = fsub fast <2 x float> %9, %10
165 %interleaved.vec = shufflevector <2 x float> %11, <2 x float> %8, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
166 ret <4 x float> %interleaved.vec
167 }
168
169
170 ; d * (b * a) * (c * a)
171 ; Expected to transform
172 define arm_aapcs_vfpcc <4 x float> @mul_diamond(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d) {
173 ; CHECK-LABEL: mul_diamond:
174 ; CHECK: @ %bb.0: @ %entry
175 ; CHECK-NEXT: .vsave {d8, d9}
176 ; CHECK-NEXT: vpush {d8, d9}
177 ; CHECK-NEXT: vcmul.f32 q4, q1, q0, #0
178 ; CHECK-NEXT: vcmla.f32 q4, q1, q0, #90
179 ; CHECK-NEXT: vcmul.f32 q1, q4, q3, #0
180 ; CHECK-NEXT: vcmla.f32 q1, q4, q3, #90
181 ; CHECK-NEXT: vcmul.f32 q3, q2, q0, #0
182 ; CHECK-NEXT: vcmla.f32 q3, q2, q0, #90
183 ; CHECK-NEXT: vcmul.f32 q0, q3, q1, #0
184 ; CHECK-NEXT: vcmla.f32 q0, q3, q1, #90
185 ; CHECK-NEXT: vpop {d8, d9}
186 ; CHECK-NEXT: bx lr
187 entry:
188 %a.real = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
189 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
190 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
191 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
192 %c.real = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
193 %c.imag = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
194 %d.real = shufflevector <4 x float> %d, <4 x float> poison, <2 x i32> <i32 0, i32 2>
195 %d.imag = shufflevector <4 x float> %d, <4 x float> poison, <2 x i32> <i32 1, i32 3>
196 %0 = fmul fast <2 x float> %a.imag, %b.real
197 %1 = fmul fast <2 x float> %a.real, %b.imag
198 %2 = fadd fast <2 x float> %1, %0
199 %3 = fmul fast <2 x float> %a.real, %b.real
200 %4 = fmul fast <2 x float> %b.imag, %a.imag
201 %5 = fsub fast <2 x float> %3, %4
202 %6 = fmul fast <2 x float> %d.real, %5
203 %7 = fmul fast <2 x float> %2, %d.imag
204 %8 = fmul fast <2 x float> %d.real, %2
205 %9 = fmul fast <2 x float> %5, %d.imag
206 %10 = fsub fast <2 x float> %6, %7
207 %11 = fadd fast <2 x float> %8, %9
208 %12 = fmul fast <2 x float> %c.real, %a.imag
209 %13 = fmul fast <2 x float> %c.imag, %a.real
210 %14 = fadd fast <2 x float> %13, %12
211 %15 = fmul fast <2 x float> %14, %10
212 %16 = fmul fast <2 x float> %c.real, %a.real
213 %17 = fmul fast <2 x float> %c.imag, %a.imag
214 %18 = fsub fast <2 x float> %16, %17
215 %19 = fmul fast <2 x float> %18, %11
216 %20 = fadd fast <2 x float> %15, %19
217 %21 = fmul fast <2 x float> %18, %10
218 %22 = fmul fast <2 x float> %14, %11
219 %23 = fsub fast <2 x float> %21, %22
220 %interleaved.vec = shufflevector <2 x float> %23, <2 x float> %20, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
221 ret <4 x float> %interleaved.vec
222 }
223
224 ; Expected to transform
225 define arm_aapcs_vfpcc <4 x float> @mul_add90_mul(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
226 ; CHECK-LABEL: mul_add90_mul:
227 ; CHECK: @ %bb.0: @ %entry
228 ; CHECK-NEXT: .vsave {d8, d9}
229 ; CHECK-NEXT: vpush {d8, d9}
230 ; CHECK-NEXT: vcmul.f32 q3, q2, q0, #0
231 ; CHECK-NEXT: vcmul.f32 q4, q1, q0, #0
232 ; CHECK-NEXT: vcmla.f32 q4, q1, q0, #90
233 ; CHECK-NEXT: vcmla.f32 q3, q2, q0, #90
234 ; CHECK-NEXT: vcadd.f32 q0, q3, q4, #90
235 ; CHECK-NEXT: vpop {d8, d9}
236 ; CHECK-NEXT: bx lr
237 entry:
238 %ar = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
239 %ai = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
240 %br = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
241 %bi = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
242 %cr = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
243 %ci = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
244
245 %i6 = fmul fast <2 x float> %br, %ar
246 %i7 = fmul fast <2 x float> %bi, %ai
247 %xr = fsub fast <2 x float> %i6, %i7
248 %i9 = fmul fast <2 x float> %bi, %ar
249 %i10 = fmul fast <2 x float> %br, %ai
250 %xi = fadd fast <2 x float> %i9, %i10
251
252 %j6 = fmul fast <2 x float> %cr, %ar
253 %j7 = fmul fast <2 x float> %ci, %ai
254 %yr = fsub fast <2 x float> %j6, %j7
255 %j9 = fmul fast <2 x float> %ci, %ar
256 %j10 = fmul fast <2 x float> %cr, %ai
257 %yi = fadd fast <2 x float> %j9, %j10
258
259 %zr = fsub fast <2 x float> %yr, %xi
260 %zi = fadd fast <2 x float> %yi, %xr
261 %interleaved.vec = shufflevector <2 x float> %zr, <2 x float> %zi, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
262 ret <4 x float> %interleaved.vec
263 }
264
265 ; Expected to not transform
266 define arm_aapcs_vfpcc <4 x float> @mul_triangle_addmul(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
267 ; CHECK-LABEL: mul_triangle_addmul:
268 ; CHECK: @ %bb.0: @ %entry
269 ; CHECK-NEXT: .vsave {d8, d9, d10, d11, d12, d13, d14, d15}
270 ; CHECK-NEXT: vpush {d8, d9, d10, d11, d12, d13, d14, d15}
271 ; CHECK-NEXT: vmov.f32 s16, s0
272 ; CHECK-NEXT: vmov.f32 s20, s5
273 ; CHECK-NEXT: vmov.f32 s17, s2
274 ; CHECK-NEXT: vmov.f32 s21, s7
275 ; CHECK-NEXT: vmov.f32 s5, s6
276 ; CHECK-NEXT: vmul.f32 q3, q5, q4
277 ; CHECK-NEXT: vmul.f32 q4, q1, q4
278 ; CHECK-NEXT: vmov.f32 s0, s1
279 ; CHECK-NEXT: vmov.f32 s1, s3
280 ; CHECK-NEXT: vmov q6, q4
281 ; CHECK-NEXT: vfms.f32 q6, q5, q0
282 ; CHECK-NEXT: vmov q7, q3
283 ; CHECK-NEXT: vfma.f32 q3, q1, q0
284 ; CHECK-NEXT: vmov.f32 s20, s8
285 ; CHECK-NEXT: vmov.f32 s21, s10
286 ; CHECK-NEXT: vmov.f32 s4, s9
287 ; CHECK-NEXT: vfma.f32 q7, q5, q0
288 ; CHECK-NEXT: vmov.f32 s5, s11
289 ; CHECK-NEXT: vadd.f32 q5, q7, q6
290 ; CHECK-NEXT: vfms.f32 q4, q1, q0
291 ; CHECK-NEXT: vmov.f32 s1, s20
292 ; CHECK-NEXT: vsub.f32 q1, q4, q3
293 ; CHECK-NEXT: vmov.f32 s3, s21
294 ; CHECK-NEXT: vmov.f32 s0, s4
295 ; CHECK-NEXT: vmov.f32 s2, s5
296 ; CHECK-NEXT: vpop {d8, d9, d10, d11, d12, d13, d14, d15}
297 ; CHECK-NEXT: bx lr
298 entry:
299 %ar = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
300 %ai = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
301 %br = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
302 %bi = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
303 %cr = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
304 %ci = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
305
306 %i6 = fmul fast <2 x float> %br, %ar
307 %i7 = fmul fast <2 x float> %bi, %ai
308 %xr = fsub fast <2 x float> %i6, %i7
309 %i9 = fmul fast <2 x float> %bi, %ar
310 %i10 = fmul fast <2 x float> %br, %ai
311 %xi = fadd fast <2 x float> %i9, %i10
312
313 ;%j6 = fmul fast <2 x float> %cr, %ar
314 %j7 = fmul fast <2 x float> %ci, %ai
315 %yr = fsub fast <2 x float> %i6, %j7
316 ;%j9 = fmul fast <2 x float> %ci, %ar
317 %j10 = fmul fast <2 x float> %cr, %ai
318 %yi = fadd fast <2 x float> %i9, %j10
319
320 %zr = fsub fast <2 x float> %yr, %xi
321 %zi = fadd fast <2 x float> %yi, %xr
322 %interleaved.vec = shufflevector <2 x float> %zr, <2 x float> %zi, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
323 ret <4 x float> %interleaved.vec
324 }
325
326 ; Expected to not transform
327 define arm_aapcs_vfpcc <4 x float> @mul_triangle_multiuses(<4 x float> %a, <4 x float> %b, ptr %p) {
328 ; CHECK-LABEL: mul_triangle_multiuses:
329 ; CHECK: @ %bb.0: @ %entry
330 ; CHECK-NEXT: .vsave {d8, d9}
331 ; CHECK-NEXT: vpush {d8, d9}
332 ; CHECK-NEXT: vmov.f32 s16, s4
333 ; CHECK-NEXT: vmov.f32 s8, s1
334 ; CHECK-NEXT: vmov.f32 s17, s6
335 ; CHECK-NEXT: vmov.f32 s9, s3
336 ; CHECK-NEXT: vmov.f32 s4, s5
337 ; CHECK-NEXT: vmul.f32 q3, q2, q4
338 ; CHECK-NEXT: vmov.f32 s1, s2
339 ; CHECK-NEXT: vmov.f32 s5, s7
340 ; CHECK-NEXT: vfma.f32 q3, q1, q0
341 ; CHECK-NEXT: vmul.f32 q1, q1, q2
342 ; CHECK-NEXT: vneg.f32 q1, q1
343 ; CHECK-NEXT: vfma.f32 q1, q4, q0
344 ; CHECK-NEXT: vmov.f32 s18, s12
345 ; CHECK-NEXT: vmov.f32 s16, s4
346 ; CHECK-NEXT: vmov.f32 s17, s5
347 ; CHECK-NEXT: vmov.f32 s19, s13
348 ; CHECK-NEXT: vstrw.32 q4, [r0]
349 ; CHECK-NEXT: vmul.f32 q4, q3, q0
350 ; CHECK-NEXT: vfma.f32 q4, q1, q2
351 ; CHECK-NEXT: vmul.f32 q2, q3, q2
352 ; CHECK-NEXT: vneg.f32 q2, q2
353 ; CHECK-NEXT: vfma.f32 q2, q1, q0
354 ; CHECK-NEXT: vmov.f32 s1, s16
355 ; CHECK-NEXT: vmov.f32 s0, s8
356 ; CHECK-NEXT: vmov.f32 s2, s9
357 ; CHECK-NEXT: vmov.f32 s3, s17
358 ; CHECK-NEXT: vpop {d8, d9}
359 ; CHECK-NEXT: bx lr
360 entry:
361 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
362 %strided.vec35 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
363 %strided.vec37 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
364 %strided.vec38 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
365 %0 = fmul fast <2 x float> %strided.vec37, %strided.vec
366 %1 = fmul fast <2 x float> %strided.vec38, %strided.vec35
367 %2 = fsub fast <2 x float> %0, %1
368 %3 = fmul fast <2 x float> %2, %strided.vec35
369 %4 = fmul fast <2 x float> %strided.vec38, %strided.vec
370 %5 = fmul fast <2 x float> %strided.vec35, %strided.vec37
371 %6 = fadd fast <2 x float> %4, %5
372 %otheruse = shufflevector <2 x float> %2, <2 x float> %6, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
373 store <4 x float> %otheruse, ptr %p
374 %7 = fmul fast <2 x float> %6, %strided.vec
375 %8 = fadd fast <2 x float> %3, %7
376 %9 = fmul fast <2 x float> %2, %strided.vec
377 %10 = fmul fast <2 x float> %6, %strided.vec35
378 %11 = fsub fast <2 x float> %9, %10
379 %interleaved.vec = shufflevector <2 x float> %11, <2 x float> %8, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
380 ret <4 x float> %interleaved.vec
381 }
382
383 ; Expected to transform
384 define <4 x float> @mul_addequal(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
385 ; CHECK-LABEL: mul_addequal:
386 ; CHECK: @ %bb.0: @ %entry
387 ; CHECK-NEXT: add.w r12, sp, #16
388 ; CHECK-NEXT: vmov d0, r0, r1
389 ; CHECK-NEXT: mov r0, sp
390 ; CHECK-NEXT: vldrw.u32 q2, [r12]
391 ; CHECK-NEXT: vldrw.u32 q1, [r0]
392 ; CHECK-NEXT: vmov d1, r2, r3
393 ; CHECK-NEXT: vcmla.f32 q2, q0, q1, #0
394 ; CHECK-NEXT: vcmla.f32 q2, q0, q1, #90
395 ; CHECK-NEXT: vmov r0, r1, d4
396 ; CHECK-NEXT: vmov r2, r3, d5
397 ; CHECK-NEXT: bx lr
398 entry:
399 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
400 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
401 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
402 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
403 %0 = fmul fast <2 x float> %b.imag, %strided.vec
404 %1 = fmul fast <2 x float> %b.real, %a.imag
405 %2 = fadd fast <2 x float> %1, %0
406 %3 = fmul fast <2 x float> %b.real, %strided.vec
407 %4 = fmul fast <2 x float> %a.imag, %b.imag
408 %5 = fsub fast <2 x float> %3, %4
409 %c.real = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
410 %c.imag = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
411 %6 = fadd fast <2 x float> %5, %c.real
412 %7 = fadd fast <2 x float> %2, %c.imag
413 %interleaved.vec = shufflevector <2 x float> %6, <2 x float> %7, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
414 ret <4 x float> %interleaved.vec
415 }
416
417 ; Expected to transform
418 define <4 x float> @mul_subequal(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
419 ; CHECK-LABEL: mul_subequal:
420 ; CHECK: @ %bb.0: @ %entry
421 ; CHECK-NEXT: vmov d0, r0, r1
422 ; CHECK-NEXT: mov r1, sp
423 ; CHECK-NEXT: vldrw.u32 q2, [r1]
424 ; CHECK-NEXT: vmov d1, r2, r3
425 ; CHECK-NEXT: add r0, sp, #16
426 ; CHECK-NEXT: vcmul.f32 q3, q0, q2, #0
427 ; CHECK-NEXT: vldrw.u32 q1, [r0]
428 ; CHECK-NEXT: vcmla.f32 q3, q0, q2, #90
429 ; CHECK-NEXT: vsub.f32 q0, q3, q1
430 ; CHECK-NEXT: vmov r0, r1, d0
431 ; CHECK-NEXT: vmov r2, r3, d1
432 ; CHECK-NEXT: bx lr
433 entry:
434 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
435 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
436 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
437 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
438 %0 = fmul fast <2 x float> %b.imag, %strided.vec
439 %1 = fmul fast <2 x float> %b.real, %a.imag
440 %2 = fadd fast <2 x float> %1, %0
441 %3 = fmul fast <2 x float> %b.real, %strided.vec
442 %4 = fmul fast <2 x float> %a.imag, %b.imag
443 %5 = fsub fast <2 x float> %3, %4
444 %c.real = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
445 %c.imag = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
446 %6 = fsub fast <2 x float> %5, %c.real
447 %7 = fsub fast <2 x float> %2, %c.imag
448 %interleaved.vec = shufflevector <2 x float> %6, <2 x float> %7, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
449 ret <4 x float> %interleaved.vec
450 }
451
452
453 ; Expected to transform
454 define <4 x float> @mul_mulequal(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
455 ; CHECK-LABEL: mul_mulequal:
456 ; CHECK: @ %bb.0: @ %entry
457 ; CHECK-NEXT: vmov d0, r0, r1
458 ; CHECK-NEXT: mov r1, sp
459 ; CHECK-NEXT: vldrw.u32 q2, [r1]
460 ; CHECK-NEXT: vmov d1, r2, r3
461 ; CHECK-NEXT: add r0, sp, #16
462 ; CHECK-NEXT: vcmul.f32 q3, q0, q2, #0
463 ; CHECK-NEXT: vldrw.u32 q1, [r0]
464 ; CHECK-NEXT: vcmla.f32 q3, q0, q2, #90
465 ; CHECK-NEXT: vmul.f32 q0, q3, q1
466 ; CHECK-NEXT: vmov r0, r1, d0
467 ; CHECK-NEXT: vmov r2, r3, d1
468 ; CHECK-NEXT: bx lr
469 entry:
470 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
471 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
472 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
473 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
474 %0 = fmul fast <2 x float> %b.imag, %strided.vec
475 %1 = fmul fast <2 x float> %b.real, %a.imag
476 %2 = fadd fast <2 x float> %1, %0
477 %3 = fmul fast <2 x float> %b.real, %strided.vec
478 %4 = fmul fast <2 x float> %a.imag, %b.imag
479 %5 = fsub fast <2 x float> %3, %4
480 %c.real = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
481 %c.imag = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
482 %6 = fmul fast <2 x float> %5, %c.real
483 %7 = fmul fast <2 x float> %2, %c.imag
484 %interleaved.vec = shufflevector <2 x float> %6, <2 x float> %7, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
485 ret <4 x float> %interleaved.vec
486 }
487
488 ; Expected to not transform
489 define <4 x float> @mul_divequal(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
490 ; CHECK-LABEL: mul_divequal:
491 ; CHECK: @ %bb.0: @ %entry
492 ; CHECK-NEXT: .vsave {d10, d11}
493 ; CHECK-NEXT: vpush {d10, d11}
494 ; CHECK-NEXT: .vsave {d8}
495 ; CHECK-NEXT: vpush {d8}
496 ; CHECK-NEXT: vmov d0, r0, r1
497 ; CHECK-NEXT: add r0, sp, #24
498 ; CHECK-NEXT: vldrw.u32 q1, [r0]
499 ; CHECK-NEXT: vmov d1, r2, r3
500 ; CHECK-NEXT: vmov.f32 s16, s1
501 ; CHECK-NEXT: add.w r12, sp, #40
502 ; CHECK-NEXT: vmov.f32 s12, s5
503 ; CHECK-NEXT: vmov.f32 s13, s7
504 ; CHECK-NEXT: vmov.f32 s1, s2
505 ; CHECK-NEXT: vmov.f32 s8, s4
506 ; CHECK-NEXT: vmul.f32 q5, q3, q0
507 ; CHECK-NEXT: vmov.f32 s9, s6
508 ; CHECK-NEXT: vldrw.u32 q1, [r12]
509 ; CHECK-NEXT: vmov.f32 s17, s3
510 ; CHECK-NEXT: vfma.f32 q5, q2, q4
511 ; CHECK-NEXT: vmul.f32 q3, q4, q3
512 ; CHECK-NEXT: vdiv.f32 s3, s21, s7
513 ; CHECK-NEXT: vneg.f32 q3, q3
514 ; CHECK-NEXT: vfma.f32 q3, q2, q0
515 ; CHECK-NEXT: vdiv.f32 s1, s20, s5
516 ; CHECK-NEXT: vdiv.f32 s2, s13, s6
517 ; CHECK-NEXT: vdiv.f32 s0, s12, s4
518 ; CHECK-NEXT: vmov r0, r1, d0
519 ; CHECK-NEXT: vmov r2, r3, d1
520 ; CHECK-NEXT: vpop {d8}
521 ; CHECK-NEXT: vpop {d10, d11}
522 ; CHECK-NEXT: bx lr
523 entry:
524 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
525 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
526 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
527 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
528 %0 = fmul fast <2 x float> %b.imag, %strided.vec
529 %1 = fmul fast <2 x float> %b.real, %a.imag
530 %2 = fadd fast <2 x float> %1, %0
531 %3 = fmul fast <2 x float> %b.real, %strided.vec
532 %4 = fmul fast <2 x float> %a.imag, %b.imag
533 %5 = fsub fast <2 x float> %3, %4
534 %c.real = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
535 %c.imag = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
536 %6 = fdiv fast <2 x float> %5, %c.real
537 %7 = fdiv fast <2 x float> %2, %c.imag
538 %interleaved.vec = shufflevector <2 x float> %6, <2 x float> %7, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
539 ret <4 x float> %interleaved.vec
540 }
541
542 ; Expected to transform
543 define <4 x float> @mul_negequal(<4 x float> %a, <4 x float> %b) {
544 ; CHECK-LABEL: mul_negequal:
545 ; CHECK: @ %bb.0: @ %entry
546 ; CHECK-NEXT: vmov d0, r0, r1
547 ; CHECK-NEXT: mov r0, sp
548 ; CHECK-NEXT: vldrw.u32 q1, [r0]
549 ; CHECK-NEXT: vmov d1, r2, r3
550 ; CHECK-NEXT: vcmul.f32 q2, q0, q1, #180
551 ; CHECK-NEXT: vcmla.f32 q2, q0, q1, #270
552 ; CHECK-NEXT: vmov r0, r1, d4
553 ; CHECK-NEXT: vmov r2, r3, d5
554 ; CHECK-NEXT: bx lr
555 entry:
556 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
557 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
558 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
559 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
560 %0 = fmul fast <2 x float> %b.imag, %strided.vec
561 %1 = fmul fast <2 x float> %b.real, %a.imag
562 %2 = fadd fast <2 x float> %1, %0
563 %3 = fmul fast <2 x float> %b.real, %strided.vec
564 %4 = fmul fast <2 x float> %a.imag, %b.imag
565 %5 = fsub fast <2 x float> %3, %4
566 %6 = fneg fast <2 x float> %5
567 %7 = fneg fast <2 x float> %2
568 %interleaved.vec = shufflevector <2 x float> %6, <2 x float> %7, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
569 ret <4 x float> %interleaved.vec
570 }