1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O3 -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256
3 ; RUN: llc -O3 -aarch64-sve-vector-bits-min=512 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
4 ; RUN: llc -O3 -aarch64-sve-vector-bits-min=2048 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
6 target triple = "aarch64-unknown-linux-gnu"
12 ; Don't use SVE for 64-bit vectors.
13 define <4 x half> @fma_v4f16(<4 x half> %op1, <4 x half> %op2, <4 x half> %op3) vscale_range(2,0) #0 {
14 ; CHECK-LABEL: fma_v4f16:
16 ; CHECK-NEXT: fmla v2.4h, v0.4h, v1.4h
17 ; CHECK-NEXT: fmov d0, d2
19 %mul = fmul contract <4 x half> %op1, %op2
20 %res = fadd contract <4 x half> %mul, %op3
24 ; Don't use SVE for 128-bit vectors.
25 define <8 x half> @fma_v8f16(<8 x half> %op1, <8 x half> %op2, <8 x half> %op3) vscale_range(2,0) #0 {
26 ; CHECK-LABEL: fma_v8f16:
28 ; CHECK-NEXT: fmla v2.8h, v0.8h, v1.8h
29 ; CHECK-NEXT: mov v0.16b, v2.16b
31 %mul = fmul contract <8 x half> %op1, %op2
32 %res = fadd contract <8 x half> %mul, %op3
36 define void @fma_v16f16(ptr %a, ptr %b, ptr %c) vscale_range(2,0) #0 {
37 ; CHECK-LABEL: fma_v16f16:
39 ; CHECK-NEXT: ptrue p0.h, vl16
40 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
41 ; CHECK-NEXT: ld1h { z1.h }, p0/z, [x1]
42 ; CHECK-NEXT: ld1h { z2.h }, p0/z, [x2]
43 ; CHECK-NEXT: fmad z0.h, p0/m, z1.h, z2.h
44 ; CHECK-NEXT: st1h { z0.h }, p0, [x0]
46 %op1 = load <16 x half>, ptr %a
47 %op2 = load <16 x half>, ptr %b
48 %op3 = load <16 x half>, ptr %c
49 %mul = fmul contract <16 x half> %op1, %op2
50 %res = fadd contract <16 x half> %mul, %op3
51 store <16 x half> %res, ptr %a
55 define void @fma_v32f16(ptr %a, ptr %b, ptr %c) #0 {
56 ; VBITS_GE_256-LABEL: fma_v32f16:
57 ; VBITS_GE_256: // %bb.0:
58 ; VBITS_GE_256-NEXT: ptrue p0.h, vl16
59 ; VBITS_GE_256-NEXT: mov x8, #16 // =0x10
60 ; VBITS_GE_256-NEXT: ld1h { z0.h }, p0/z, [x0, x8, lsl #1]
61 ; VBITS_GE_256-NEXT: ld1h { z1.h }, p0/z, [x0]
62 ; VBITS_GE_256-NEXT: ld1h { z2.h }, p0/z, [x1, x8, lsl #1]
63 ; VBITS_GE_256-NEXT: ld1h { z3.h }, p0/z, [x1]
64 ; VBITS_GE_256-NEXT: ld1h { z4.h }, p0/z, [x2, x8, lsl #1]
65 ; VBITS_GE_256-NEXT: ld1h { z5.h }, p0/z, [x2]
66 ; VBITS_GE_256-NEXT: fmad z0.h, p0/m, z2.h, z4.h
67 ; VBITS_GE_256-NEXT: fmad z1.h, p0/m, z3.h, z5.h
68 ; VBITS_GE_256-NEXT: st1h { z0.h }, p0, [x0, x8, lsl #1]
69 ; VBITS_GE_256-NEXT: st1h { z1.h }, p0, [x0]
70 ; VBITS_GE_256-NEXT: ret
72 ; VBITS_GE_512-LABEL: fma_v32f16:
73 ; VBITS_GE_512: // %bb.0:
74 ; VBITS_GE_512-NEXT: ptrue p0.h, vl32
75 ; VBITS_GE_512-NEXT: ld1h { z0.h }, p0/z, [x0]
76 ; VBITS_GE_512-NEXT: ld1h { z1.h }, p0/z, [x1]
77 ; VBITS_GE_512-NEXT: ld1h { z2.h }, p0/z, [x2]
78 ; VBITS_GE_512-NEXT: fmad z0.h, p0/m, z1.h, z2.h
79 ; VBITS_GE_512-NEXT: st1h { z0.h }, p0, [x0]
80 ; VBITS_GE_512-NEXT: ret
81 %op1 = load <32 x half>, ptr %a
82 %op2 = load <32 x half>, ptr %b
83 %op3 = load <32 x half>, ptr %c
84 %mul = fmul contract <32 x half> %op1, %op2
85 %res = fadd contract <32 x half> %mul, %op3
86 store <32 x half> %res, ptr %a
90 define void @fma_v64f16(ptr %a, ptr %b, ptr %c) vscale_range(8,0) #0 {
91 ; CHECK-LABEL: fma_v64f16:
93 ; CHECK-NEXT: ptrue p0.h, vl64
94 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
95 ; CHECK-NEXT: ld1h { z1.h }, p0/z, [x1]
96 ; CHECK-NEXT: ld1h { z2.h }, p0/z, [x2]
97 ; CHECK-NEXT: fmad z0.h, p0/m, z1.h, z2.h
98 ; CHECK-NEXT: st1h { z0.h }, p0, [x0]
100 %op1 = load <64 x half>, ptr %a
101 %op2 = load <64 x half>, ptr %b
102 %op3 = load <64 x half>, ptr %c
103 %mul = fmul contract <64 x half> %op1, %op2
104 %res = fadd contract <64 x half> %mul, %op3
105 store <64 x half> %res, ptr %a
109 define void @fma_v128f16(ptr %a, ptr %b, ptr %c) vscale_range(16,0) #0 {
110 ; CHECK-LABEL: fma_v128f16:
112 ; CHECK-NEXT: ptrue p0.h, vl128
113 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
114 ; CHECK-NEXT: ld1h { z1.h }, p0/z, [x1]
115 ; CHECK-NEXT: ld1h { z2.h }, p0/z, [x2]
116 ; CHECK-NEXT: fmad z0.h, p0/m, z1.h, z2.h
117 ; CHECK-NEXT: st1h { z0.h }, p0, [x0]
119 %op1 = load <128 x half>, ptr %a
120 %op2 = load <128 x half>, ptr %b
121 %op3 = load <128 x half>, ptr %c
122 %mul = fmul contract <128 x half> %op1, %op2
123 %res = fadd contract <128 x half> %mul, %op3
124 store <128 x half> %res, ptr %a
128 ; Don't use SVE for 64-bit vectors.
129 define <2 x float> @fma_v2f32(<2 x float> %op1, <2 x float> %op2, <2 x float> %op3) vscale_range(2,0) #0 {
130 ; CHECK-LABEL: fma_v2f32:
132 ; CHECK-NEXT: fmla v2.2s, v0.2s, v1.2s
133 ; CHECK-NEXT: fmov d0, d2
135 %mul = fmul contract <2 x float> %op1, %op2
136 %res = fadd contract <2 x float> %mul, %op3
140 ; Don't use SVE for 128-bit vectors.
141 define <4 x float> @fma_v4f32(<4 x float> %op1, <4 x float> %op2, <4 x float> %op3) vscale_range(2,0) #0 {
142 ; CHECK-LABEL: fma_v4f32:
144 ; CHECK-NEXT: fmla v2.4s, v0.4s, v1.4s
145 ; CHECK-NEXT: mov v0.16b, v2.16b
147 %mul = fmul contract <4 x float> %op1, %op2
148 %res = fadd contract <4 x float> %mul, %op3
152 define void @fma_v8f32(ptr %a, ptr %b, ptr %c) vscale_range(2,0) #0 {
153 ; CHECK-LABEL: fma_v8f32:
155 ; CHECK-NEXT: ptrue p0.s, vl8
156 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
157 ; CHECK-NEXT: ld1w { z1.s }, p0/z, [x1]
158 ; CHECK-NEXT: ld1w { z2.s }, p0/z, [x2]
159 ; CHECK-NEXT: fmad z0.s, p0/m, z1.s, z2.s
160 ; CHECK-NEXT: st1w { z0.s }, p0, [x0]
162 %op1 = load <8 x float>, ptr %a
163 %op2 = load <8 x float>, ptr %b
164 %op3 = load <8 x float>, ptr %c
165 %mul = fmul contract <8 x float> %op1, %op2
166 %res = fadd contract <8 x float> %mul, %op3
167 store <8 x float> %res, ptr %a
171 define void @fma_v16f32(ptr %a, ptr %b, ptr %c) #0 {
172 ; VBITS_GE_256-LABEL: fma_v16f32:
173 ; VBITS_GE_256: // %bb.0:
174 ; VBITS_GE_256-NEXT: ptrue p0.s, vl8
175 ; VBITS_GE_256-NEXT: mov x8, #8 // =0x8
176 ; VBITS_GE_256-NEXT: ld1w { z0.s }, p0/z, [x0, x8, lsl #2]
177 ; VBITS_GE_256-NEXT: ld1w { z1.s }, p0/z, [x0]
178 ; VBITS_GE_256-NEXT: ld1w { z2.s }, p0/z, [x1, x8, lsl #2]
179 ; VBITS_GE_256-NEXT: ld1w { z3.s }, p0/z, [x1]
180 ; VBITS_GE_256-NEXT: ld1w { z4.s }, p0/z, [x2, x8, lsl #2]
181 ; VBITS_GE_256-NEXT: ld1w { z5.s }, p0/z, [x2]
182 ; VBITS_GE_256-NEXT: fmad z0.s, p0/m, z2.s, z4.s
183 ; VBITS_GE_256-NEXT: fmad z1.s, p0/m, z3.s, z5.s
184 ; VBITS_GE_256-NEXT: st1w { z0.s }, p0, [x0, x8, lsl #2]
185 ; VBITS_GE_256-NEXT: st1w { z1.s }, p0, [x0]
186 ; VBITS_GE_256-NEXT: ret
188 ; VBITS_GE_512-LABEL: fma_v16f32:
189 ; VBITS_GE_512: // %bb.0:
190 ; VBITS_GE_512-NEXT: ptrue p0.s, vl16
191 ; VBITS_GE_512-NEXT: ld1w { z0.s }, p0/z, [x0]
192 ; VBITS_GE_512-NEXT: ld1w { z1.s }, p0/z, [x1]
193 ; VBITS_GE_512-NEXT: ld1w { z2.s }, p0/z, [x2]
194 ; VBITS_GE_512-NEXT: fmad z0.s, p0/m, z1.s, z2.s
195 ; VBITS_GE_512-NEXT: st1w { z0.s }, p0, [x0]
196 ; VBITS_GE_512-NEXT: ret
197 %op1 = load <16 x float>, ptr %a
198 %op2 = load <16 x float>, ptr %b
199 %op3 = load <16 x float>, ptr %c
200 %mul = fmul contract <16 x float> %op1, %op2
201 %res = fadd contract <16 x float> %mul, %op3
202 store <16 x float> %res, ptr %a
206 define void @fma_v32f32(ptr %a, ptr %b, ptr %c) vscale_range(8,0) #0 {
207 ; CHECK-LABEL: fma_v32f32:
209 ; CHECK-NEXT: ptrue p0.s, vl32
210 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
211 ; CHECK-NEXT: ld1w { z1.s }, p0/z, [x1]
212 ; CHECK-NEXT: ld1w { z2.s }, p0/z, [x2]
213 ; CHECK-NEXT: fmad z0.s, p0/m, z1.s, z2.s
214 ; CHECK-NEXT: st1w { z0.s }, p0, [x0]
216 %op1 = load <32 x float>, ptr %a
217 %op2 = load <32 x float>, ptr %b
218 %op3 = load <32 x float>, ptr %c
219 %mul = fmul contract <32 x float> %op1, %op2
220 %res = fadd contract <32 x float> %mul, %op3
221 store <32 x float> %res, ptr %a
225 define void @fma_v64f32(ptr %a, ptr %b, ptr %c) vscale_range(16,0) #0 {
226 ; CHECK-LABEL: fma_v64f32:
228 ; CHECK-NEXT: ptrue p0.s, vl64
229 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
230 ; CHECK-NEXT: ld1w { z1.s }, p0/z, [x1]
231 ; CHECK-NEXT: ld1w { z2.s }, p0/z, [x2]
232 ; CHECK-NEXT: fmad z0.s, p0/m, z1.s, z2.s
233 ; CHECK-NEXT: st1w { z0.s }, p0, [x0]
235 %op1 = load <64 x float>, ptr %a
236 %op2 = load <64 x float>, ptr %b
237 %op3 = load <64 x float>, ptr %c
238 %mul = fmul contract <64 x float> %op1, %op2
239 %res = fadd contract <64 x float> %mul, %op3
240 store <64 x float> %res, ptr %a
244 ; Don't use SVE for 64-bit vectors.
245 define <1 x double> @fma_v1f64(<1 x double> %op1, <1 x double> %op2, <1 x double> %op3) vscale_range(2,0) #0 {
246 ; CHECK-LABEL: fma_v1f64:
248 ; CHECK-NEXT: fmadd d0, d0, d1, d2
250 %mul = fmul contract <1 x double> %op1, %op2
251 %res = fadd contract <1 x double> %mul, %op3
252 ret <1 x double> %res
255 ; Don't use SVE for 128-bit vectors.
256 define <2 x double> @fma_v2f64(<2 x double> %op1, <2 x double> %op2, <2 x double> %op3) vscale_range(2,0) #0 {
257 ; CHECK-LABEL: fma_v2f64:
259 ; CHECK-NEXT: fmla v2.2d, v0.2d, v1.2d
260 ; CHECK-NEXT: mov v0.16b, v2.16b
262 %mul = fmul contract <2 x double> %op1, %op2
263 %res = fadd contract <2 x double> %mul, %op3
264 ret <2 x double> %res
267 define void @fma_v4f64(ptr %a, ptr %b, ptr %c) vscale_range(2,0) #0 {
268 ; CHECK-LABEL: fma_v4f64:
270 ; CHECK-NEXT: ptrue p0.d, vl4
271 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
272 ; CHECK-NEXT: ld1d { z1.d }, p0/z, [x1]
273 ; CHECK-NEXT: ld1d { z2.d }, p0/z, [x2]
274 ; CHECK-NEXT: fmad z0.d, p0/m, z1.d, z2.d
275 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
277 %op1 = load <4 x double>, ptr %a
278 %op2 = load <4 x double>, ptr %b
279 %op3 = load <4 x double>, ptr %c
280 %mul = fmul contract <4 x double> %op1, %op2
281 %res = fadd contract <4 x double> %mul, %op3
282 store <4 x double> %res, ptr %a
286 define void @fma_v8f64(ptr %a, ptr %b, ptr %c) #0 {
287 ; VBITS_GE_256-LABEL: fma_v8f64:
288 ; VBITS_GE_256: // %bb.0:
289 ; VBITS_GE_256-NEXT: ptrue p0.d, vl4
290 ; VBITS_GE_256-NEXT: mov x8, #4 // =0x4
291 ; VBITS_GE_256-NEXT: ld1d { z0.d }, p0/z, [x0, x8, lsl #3]
292 ; VBITS_GE_256-NEXT: ld1d { z1.d }, p0/z, [x0]
293 ; VBITS_GE_256-NEXT: ld1d { z2.d }, p0/z, [x1, x8, lsl #3]
294 ; VBITS_GE_256-NEXT: ld1d { z3.d }, p0/z, [x1]
295 ; VBITS_GE_256-NEXT: ld1d { z4.d }, p0/z, [x2, x8, lsl #3]
296 ; VBITS_GE_256-NEXT: ld1d { z5.d }, p0/z, [x2]
297 ; VBITS_GE_256-NEXT: fmad z0.d, p0/m, z2.d, z4.d
298 ; VBITS_GE_256-NEXT: fmad z1.d, p0/m, z3.d, z5.d
299 ; VBITS_GE_256-NEXT: st1d { z0.d }, p0, [x0, x8, lsl #3]
300 ; VBITS_GE_256-NEXT: st1d { z1.d }, p0, [x0]
301 ; VBITS_GE_256-NEXT: ret
303 ; VBITS_GE_512-LABEL: fma_v8f64:
304 ; VBITS_GE_512: // %bb.0:
305 ; VBITS_GE_512-NEXT: ptrue p0.d, vl8
306 ; VBITS_GE_512-NEXT: ld1d { z0.d }, p0/z, [x0]
307 ; VBITS_GE_512-NEXT: ld1d { z1.d }, p0/z, [x1]
308 ; VBITS_GE_512-NEXT: ld1d { z2.d }, p0/z, [x2]
309 ; VBITS_GE_512-NEXT: fmad z0.d, p0/m, z1.d, z2.d
310 ; VBITS_GE_512-NEXT: st1d { z0.d }, p0, [x0]
311 ; VBITS_GE_512-NEXT: ret
312 %op1 = load <8 x double>, ptr %a
313 %op2 = load <8 x double>, ptr %b
314 %op3 = load <8 x double>, ptr %c
315 %mul = fmul contract <8 x double> %op1, %op2
316 %res = fadd contract <8 x double> %mul, %op3
317 store <8 x double> %res, ptr %a
321 define void @fma_v16f64(ptr %a, ptr %b, ptr %c) vscale_range(8,0) #0 {
322 ; CHECK-LABEL: fma_v16f64:
324 ; CHECK-NEXT: ptrue p0.d, vl16
325 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
326 ; CHECK-NEXT: ld1d { z1.d }, p0/z, [x1]
327 ; CHECK-NEXT: ld1d { z2.d }, p0/z, [x2]
328 ; CHECK-NEXT: fmad z0.d, p0/m, z1.d, z2.d
329 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
331 %op1 = load <16 x double>, ptr %a
332 %op2 = load <16 x double>, ptr %b
333 %op3 = load <16 x double>, ptr %c
334 %mul = fmul contract <16 x double> %op1, %op2
335 %res = fadd contract <16 x double> %mul, %op3
336 store <16 x double> %res, ptr %a
340 define void @fma_v32f64(ptr %a, ptr %b, ptr %c) vscale_range(16,0) #0 {
341 ; CHECK-LABEL: fma_v32f64:
343 ; CHECK-NEXT: ptrue p0.d, vl32
344 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
345 ; CHECK-NEXT: ld1d { z1.d }, p0/z, [x1]
346 ; CHECK-NEXT: ld1d { z2.d }, p0/z, [x2]
347 ; CHECK-NEXT: fmad z0.d, p0/m, z1.d, z2.d
348 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
350 %op1 = load <32 x double>, ptr %a
351 %op2 = load <32 x double>, ptr %b
352 %op3 = load <32 x double>, ptr %c
353 %mul = fmul contract <32 x double> %op1, %op2
354 %res = fadd contract <32 x double> %mul, %op3
355 store <32 x double> %res, ptr %a
359 attributes #0 = { "target-features"="+sve" }