1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s --mattr=+mve.fp,+fp64 -o - | FileCheck %s
4 target triple = "thumbv8.1m.main-none-none-eabi"
6 ; Expected to transform
7 define arm_aapcs_vfpcc <4 x float> @simple_mul(<4 x float> %a, <4 x float> %b) {
8 ; CHECK-LABEL: simple_mul:
9 ; CHECK: @ %bb.0: @ %entry
10 ; CHECK-NEXT: vcmul.f32 q2, q0, q1, #0
11 ; CHECK-NEXT: vcmla.f32 q2, q0, q1, #90
12 ; CHECK-NEXT: vmov q0, q2
15 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
16 %strided.vec17 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
17 %strided.vec19 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
18 %strided.vec20 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
19 %0 = fmul fast <2 x float> %strided.vec20, %strided.vec
20 %1 = fmul fast <2 x float> %strided.vec19, %strided.vec17
21 %2 = fadd fast <2 x float> %1, %0
22 %3 = fmul fast <2 x float> %strided.vec19, %strided.vec
23 %4 = fmul fast <2 x float> %strided.vec17, %strided.vec20
24 %5 = fsub fast <2 x float> %3, %4
25 %interleaved.vec = shufflevector <2 x float> %5, <2 x float> %2, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
26 ret <4 x float> %interleaved.vec
29 ; Expected to not transform
30 define arm_aapcs_vfpcc <4 x float> @simple_mul_no_contract(<4 x float> %a, <4 x float> %b) {
31 ; CHECK-LABEL: simple_mul_no_contract:
32 ; CHECK: @ %bb.0: @ %entry
33 ; CHECK-NEXT: .vsave {d8, d9, d10, d11}
34 ; CHECK-NEXT: vpush {d8, d9, d10, d11}
35 ; CHECK-NEXT: vmov.f32 s8, s5
36 ; CHECK-NEXT: vmov.f32 s12, s1
37 ; CHECK-NEXT: vmov.f32 s9, s7
38 ; CHECK-NEXT: vmov.f32 s13, s3
39 ; CHECK-NEXT: vmov.f32 s1, s2
40 ; CHECK-NEXT: vmul.f32 q4, q3, q2
41 ; CHECK-NEXT: vmov.f32 s5, s6
42 ; CHECK-NEXT: vmul.f32 q2, q2, q0
43 ; CHECK-NEXT: vmul.f32 q5, q1, q0
44 ; CHECK-NEXT: vfma.f32 q2, q1, q3
45 ; CHECK-NEXT: vsub.f32 q4, q5, q4
46 ; CHECK-NEXT: vmov.f32 s1, s8
47 ; CHECK-NEXT: vmov.f32 s0, s16
48 ; CHECK-NEXT: vmov.f32 s2, s17
49 ; CHECK-NEXT: vmov.f32 s3, s9
50 ; CHECK-NEXT: vpop {d8, d9, d10, d11}
53 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
54 %strided.vec17 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
55 %strided.vec19 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
56 %strided.vec20 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
57 %0 = fmul fast <2 x float> %strided.vec20, %strided.vec
58 %1 = fmul fast <2 x float> %strided.vec19, %strided.vec17
59 %2 = fadd fast <2 x float> %1, %0
60 %3 = fmul fast <2 x float> %strided.vec19, %strided.vec
61 %4 = fmul fast <2 x float> %strided.vec17, %strided.vec20
62 %5 = fsub <2 x float> %3, %4
63 %interleaved.vec = shufflevector <2 x float> %5, <2 x float> %2, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
64 ret <4 x float> %interleaved.vec
67 ; Expected to transform
68 define arm_aapcs_vfpcc <4 x float> @three_way_mul(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
69 ; CHECK-LABEL: three_way_mul:
70 ; CHECK: @ %bb.0: @ %entry
71 ; CHECK-NEXT: vcmul.f32 q3, q1, q0, #0
72 ; CHECK-NEXT: vcmla.f32 q3, q1, q0, #90
73 ; CHECK-NEXT: vcmul.f32 q0, q2, q3, #0
74 ; CHECK-NEXT: vcmla.f32 q0, q2, q3, #90
77 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
78 %strided.vec39 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
79 %strided.vec41 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
80 %strided.vec42 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
81 %strided.vec44 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 0, i32 2>
82 %strided.vec45 = shufflevector <4 x float> %c, <4 x float> poison, <2 x i32> <i32 1, i32 3>
83 %0 = fmul fast <2 x float> %strided.vec41, %strided.vec
84 %1 = fmul fast <2 x float> %strided.vec42, %strided.vec39
85 %2 = fsub fast <2 x float> %0, %1
86 %3 = fmul fast <2 x float> %2, %strided.vec45
87 %4 = fmul fast <2 x float> %strided.vec42, %strided.vec
88 %5 = fmul fast <2 x float> %strided.vec39, %strided.vec41
89 %6 = fadd fast <2 x float> %4, %5
90 %7 = fmul fast <2 x float> %6, %strided.vec44
91 %8 = fadd fast <2 x float> %3, %7
92 %9 = fmul fast <2 x float> %2, %strided.vec44
93 %10 = fmul fast <2 x float> %6, %strided.vec45
94 %11 = fsub fast <2 x float> %9, %10
95 %interleaved.vec = shufflevector <2 x float> %11, <2 x float> %8, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
96 ret <4 x float> %interleaved.vec
99 ; Expected to transform
100 define arm_aapcs_vfpcc <4 x float> @simple_add_90(<4 x float> %a, <4 x float> %b) {
101 ; CHECK-LABEL: simple_add_90:
102 ; CHECK: @ %bb.0: @ %entry
103 ; CHECK-NEXT: vcadd.f32 q2, q1, q0, #90
104 ; CHECK-NEXT: vmov q0, q2
107 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
108 %strided.vec17 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
109 %strided.vec19 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
110 %strided.vec20 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
111 %0 = fsub fast <2 x float> %strided.vec19, %strided.vec17
112 %1 = fadd fast <2 x float> %strided.vec20, %strided.vec
113 %interleaved.vec = shufflevector <2 x float> %0, <2 x float> %1, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
114 ret <4 x float> %interleaved.vec
117 ; Expected to not transform, fadd commutativity is not yet implemented
118 define arm_aapcs_vfpcc <4 x float> @simple_add_270_false(<4 x float> %a, <4 x float> %b) {
119 ; CHECK-LABEL: simple_add_270_false:
120 ; CHECK: @ %bb.0: @ %entry
121 ; CHECK-NEXT: vcadd.f32 q2, q0, q1, #270
122 ; CHECK-NEXT: vmov q0, q2
125 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
126 %strided.vec17 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
127 %strided.vec19 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
128 %strided.vec20 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
129 %0 = fadd fast <2 x float> %strided.vec20, %strided.vec
130 %1 = fsub fast <2 x float> %strided.vec17, %strided.vec19
131 %interleaved.vec = shufflevector <2 x float> %0, <2 x float> %1, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
132 ret <4 x float> %interleaved.vec
135 ; Expected to transform
136 define arm_aapcs_vfpcc <4 x float> @simple_add_270_true(<4 x float> %a, <4 x float> %b) {
137 ; CHECK-LABEL: simple_add_270_true:
138 ; CHECK: @ %bb.0: @ %entry
139 ; CHECK-NEXT: vcadd.f32 q2, q0, q1, #270
140 ; CHECK-NEXT: vmov q0, q2
143 %strided.vec = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
144 %strided.vec17 = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
145 %strided.vec19 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
146 %strided.vec20 = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
147 %0 = fadd fast <2 x float> %strided.vec, %strided.vec20
148 %1 = fsub fast <2 x float> %strided.vec17, %strided.vec19
149 %interleaved.vec = shufflevector <2 x float> %0, <2 x float> %1, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
150 ret <4 x float> %interleaved.vec
153 ; Expected to not transform
154 define arm_aapcs_vfpcc <4 x float> @add_external_use(<4 x float> %a, <4 x float> %b) {
155 ; CHECK-LABEL: add_external_use:
156 ; CHECK: @ %bb.0: @ %entry
157 ; CHECK-NEXT: vmov.f32 s8, s4
158 ; CHECK-NEXT: vmov.f32 s12, s1
159 ; CHECK-NEXT: vmov.f32 s4, s5
160 ; CHECK-NEXT: vmov.f32 s9, s6
161 ; CHECK-NEXT: vmov.f32 s13, s3
162 ; CHECK-NEXT: vmov.f32 s5, s7
163 ; CHECK-NEXT: vadd.f32 q2, q3, q2
164 ; CHECK-NEXT: vmov.f32 s1, s2
165 ; CHECK-NEXT: vsub.f32 q1, q0, q1
166 ; CHECK-NEXT: vmov.f32 s1, s8
167 ; CHECK-NEXT: vmov.f32 s0, s4
168 ; CHECK-NEXT: vmov.f32 s2, s5
169 ; CHECK-NEXT: vmov.f32 s3, s9
172 %a.real = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
173 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
174 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
175 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
176 %0 = fsub fast <2 x float> %a.real, %b.imag
177 %1 = fadd fast <2 x float> %a.imag, %b.real
178 %interleaved.vec = shufflevector <2 x float> %0, <2 x float> %1, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
179 %dup = shufflevector <2 x float> %0, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
180 %interleaved.vec2 = shufflevector <4 x float> %interleaved.vec, <4 x float> %dup, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
181 ret <4 x float> %interleaved.vec2
184 define arm_aapcs_vfpcc <4 x float> @mul_mul_with_fneg(<4 x float> %a, <4 x float> %b) {
185 ; CHECK-LABEL: mul_mul_with_fneg:
186 ; CHECK: @ %bb.0: @ %entry
187 ; CHECK-NEXT: vcmul.f32 q2, q1, q0, #270
188 ; CHECK-NEXT: vcmla.f32 q2, q1, q0, #180
189 ; CHECK-NEXT: vmov q0, q2
192 %a.real = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 0, i32 2>
193 %a.imag = shufflevector <4 x float> %a, <4 x float> poison, <2 x i32> <i32 1, i32 3>
194 %b.real = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 0, i32 2>
195 %b.imag = shufflevector <4 x float> %b, <4 x float> poison, <2 x i32> <i32 1, i32 3>
196 %0 = fneg fast <2 x float> %a.imag
197 %1 = fmul fast <2 x float> %b.real, %0
198 %2 = fmul fast <2 x float> %a.real, %b.imag
199 %3 = fsub fast <2 x float> %1, %2
200 %4 = fmul fast <2 x float> %b.imag, %a.imag
201 %5 = fmul fast <2 x float> %a.real, %b.real
202 %6 = fsub fast <2 x float> %4, %5
203 %interleaved.vec = shufflevector <2 x float> %6, <2 x float> %3, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
204 ret <4 x float> %interleaved.vec
207 ; Expected to not transform
208 define arm_aapcs_vfpcc <12 x float> @abp90c12(<12 x float> %a, <12 x float> %b, <12 x float> %c) {
209 ; CHECK-LABEL: abp90c12:
210 ; CHECK: @ %bb.0: @ %entry
211 ; CHECK-NEXT: .vsave {d8, d9, d10, d11, d12, d13, d14, d15}
212 ; CHECK-NEXT: vpush {d8, d9, d10, d11, d12, d13, d14, d15}
213 ; CHECK-NEXT: .pad #64
214 ; CHECK-NEXT: sub sp, #64
215 ; CHECK-NEXT: vldr s23, [sp, #140]
216 ; CHECK-NEXT: vmov.f32 s20, s13
217 ; CHECK-NEXT: vldr s22, [sp, #132]
218 ; CHECK-NEXT: vmov.f32 s25, s11
219 ; CHECK-NEXT: vmov.f32 s13, s10
220 ; CHECK-NEXT: vldr s19, [sp, #136]
221 ; CHECK-NEXT: vmov.f32 s11, s6
222 ; CHECK-NEXT: vldr s18, [sp, #128]
223 ; CHECK-NEXT: vmov.f32 s6, s5
224 ; CHECK-NEXT: vldr s31, [sp, #188]
225 ; CHECK-NEXT: vmov.f32 s10, s4
226 ; CHECK-NEXT: vldr s30, [sp, #180]
227 ; CHECK-NEXT: vmov.f32 s21, s15
228 ; CHECK-NEXT: vldr s29, [sp, #172]
229 ; CHECK-NEXT: vmov.f32 s5, s3
230 ; CHECK-NEXT: vldr s28, [sp, #164]
231 ; CHECK-NEXT: vmov.f32 s4, s1
232 ; CHECK-NEXT: vmov.f32 s24, s9
233 ; CHECK-NEXT: vmov.f32 s16, s12
234 ; CHECK-NEXT: vstrw.32 q6, [sp, #32] @ 16-byte Spill
235 ; CHECK-NEXT: vmov.f32 s12, s8
236 ; CHECK-NEXT: vldr s27, [sp, #184]
237 ; CHECK-NEXT: vmov.f32 s17, s14
238 ; CHECK-NEXT: vldr s26, [sp, #176]
239 ; CHECK-NEXT: vmov.f32 s9, s2
240 ; CHECK-NEXT: vldr s25, [sp, #168]
241 ; CHECK-NEXT: vmov.f32 s8, s0
242 ; CHECK-NEXT: vmul.f32 q0, q5, q1
243 ; CHECK-NEXT: vmul.f32 q1, q4, q1
244 ; CHECK-NEXT: vneg.f32 q0, q0
245 ; CHECK-NEXT: vldr s24, [sp, #160]
246 ; CHECK-NEXT: vfma.f32 q1, q5, q2
247 ; CHECK-NEXT: vstrw.32 q0, [sp, #16] @ 16-byte Spill
248 ; CHECK-NEXT: vstrw.32 q3, [sp, #48] @ 16-byte Spill
249 ; CHECK-NEXT: vsub.f32 q6, q6, q1
250 ; CHECK-NEXT: vldrw.u32 q1, [sp, #16] @ 16-byte Reload
251 ; CHECK-NEXT: vldr s13, [sp, #156]
252 ; CHECK-NEXT: vfma.f32 q1, q4, q2
253 ; CHECK-NEXT: vldr s12, [sp, #148]
254 ; CHECK-NEXT: vadd.f32 q1, q7, q1
255 ; CHECK-NEXT: vldrw.u32 q7, [sp, #32] @ 16-byte Reload
256 ; CHECK-NEXT: vldr s1, [sp, #152]
257 ; CHECK-NEXT: vstrw.32 q3, [sp] @ 16-byte Spill
258 ; CHECK-NEXT: vmul.f32 q2, q3, q7
259 ; CHECK-NEXT: vldr s0, [sp, #144]
260 ; CHECK-NEXT: vldrw.u32 q3, [sp, #48] @ 16-byte Reload
261 ; CHECK-NEXT: vneg.f32 q2, q2
262 ; CHECK-NEXT: vldr s21, [sp, #200]
263 ; CHECK-NEXT: vfma.f32 q2, q0, q3
264 ; CHECK-NEXT: vmul.f32 q0, q0, q7
265 ; CHECK-NEXT: vldrw.u32 q7, [sp] @ 16-byte Reload
266 ; CHECK-NEXT: vldr s20, [sp, #192]
267 ; CHECK-NEXT: vldr s17, [sp, #204]
268 ; CHECK-NEXT: vldr s16, [sp, #196]
269 ; CHECK-NEXT: vfma.f32 q0, q7, q3
270 ; CHECK-NEXT: vsub.f32 q3, q5, q0
271 ; CHECK-NEXT: vmov.f32 s1, s4
272 ; CHECK-NEXT: vadd.f32 q4, q4, q2
273 ; CHECK-NEXT: vmov.f32 s3, s5
274 ; CHECK-NEXT: vmov.f32 s5, s6
275 ; CHECK-NEXT: vmov.f32 s0, s24
276 ; CHECK-NEXT: vmov.f32 s2, s25
277 ; CHECK-NEXT: vmov.f32 s4, s26
278 ; CHECK-NEXT: vmov.f32 s6, s27
279 ; CHECK-NEXT: vmov.f32 s8, s12
280 ; CHECK-NEXT: vmov.f32 s9, s16
281 ; CHECK-NEXT: vmov.f32 s10, s13
282 ; CHECK-NEXT: vmov.f32 s11, s17
283 ; CHECK-NEXT: add sp, #64
284 ; CHECK-NEXT: vpop {d8, d9, d10, d11, d12, d13, d14, d15}
287 %ar = shufflevector <12 x float> %a, <12 x float> poison, <6 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10>
288 %ai = shufflevector <12 x float> %a, <12 x float> poison, <6 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11>
289 %br = shufflevector <12 x float> %b, <12 x float> poison, <6 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10>
290 %bi = shufflevector <12 x float> %b, <12 x float> poison, <6 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11>
291 %cr = shufflevector <12 x float> %c, <12 x float> poison, <6 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10>
292 %ci = shufflevector <12 x float> %c, <12 x float> poison, <6 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11>
294 %i6 = fmul fast <6 x float> %br, %ar
295 %i7 = fmul fast <6 x float> %bi, %ai
296 %xr = fsub fast <6 x float> %i6, %i7
297 %i9 = fmul fast <6 x float> %bi, %ar
298 %i10 = fmul fast <6 x float> %br, %ai
299 %xi = fadd fast <6 x float> %i9, %i10
301 %zr = fsub fast <6 x float> %cr, %xi
302 %zi = fadd fast <6 x float> %ci, %xr
303 %interleaved.vec = shufflevector <6 x float> %zr, <6 x float> %zi, <12 x i32> <i32 0, i32 6, i32 1, i32 7, i32 2, i32 8, i32 3, i32 9, i32 4, i32 10, i32 5, i32 11>
304 ret <12 x float> %interleaved.vec