1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+v,+d -mattr=+d -O0 < %s \
3 ; RUN: | FileCheck --check-prefix=SPILL-O0 %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+v,+d -mattr=+d -O2 < %s \
5 ; RUN: | FileCheck --check-prefix=SPILL-O2 %s
6 ; RUN: llc -mtriple=riscv64 -mattr=+v,+d -mattr=+d -riscv-v-vector-bits-max=128 -O2 < %s \
7 ; RUN: | FileCheck --check-prefix=SPILL-O2-VLEN128 %s
10 @.str = private unnamed_addr constant [6 x i8] c"hello\00", align 1
12 define <vscale x 1 x double> @foo(<vscale x 1 x double> %a, <vscale x 1 x double> %b, <vscale x 1 x double> %c, i64 %gvl) nounwind
13 ; SPILL-O0-LABEL: foo:
15 ; SPILL-O0-NEXT: addi sp, sp, -48
16 ; SPILL-O0-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
17 ; SPILL-O0-NEXT: csrr a1, vlenb
18 ; SPILL-O0-NEXT: slli a1, a1, 1
19 ; SPILL-O0-NEXT: sub sp, sp, a1
20 ; SPILL-O0-NEXT: sd a0, 16(sp) # 8-byte Folded Spill
21 ; SPILL-O0-NEXT: vmv1r.v v10, v9
22 ; SPILL-O0-NEXT: vmv1r.v v9, v8
23 ; SPILL-O0-NEXT: csrr a1, vlenb
24 ; SPILL-O0-NEXT: add a1, sp, a1
25 ; SPILL-O0-NEXT: addi a1, a1, 32
26 ; SPILL-O0-NEXT: vs1r.v v9, (a1) # Unknown-size Folded Spill
27 ; SPILL-O0-NEXT: # implicit-def: $v8
28 ; SPILL-O0-NEXT: vsetvli zero, a0, e64, m1, tu, ma
29 ; SPILL-O0-NEXT: vfadd.vv v8, v9, v10
30 ; SPILL-O0-NEXT: addi a0, sp, 32
31 ; SPILL-O0-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
32 ; SPILL-O0-NEXT: lui a0, %hi(.L.str)
33 ; SPILL-O0-NEXT: addi a0, a0, %lo(.L.str)
34 ; SPILL-O0-NEXT: call puts
35 ; SPILL-O0-NEXT: addi a1, sp, 32
36 ; SPILL-O0-NEXT: vl1r.v v10, (a1) # Unknown-size Folded Reload
37 ; SPILL-O0-NEXT: csrr a1, vlenb
38 ; SPILL-O0-NEXT: add a1, sp, a1
39 ; SPILL-O0-NEXT: addi a1, a1, 32
40 ; SPILL-O0-NEXT: vl1r.v v9, (a1) # Unknown-size Folded Reload
41 ; SPILL-O0-NEXT: # kill: def $x11 killed $x10
42 ; SPILL-O0-NEXT: ld a0, 16(sp) # 8-byte Folded Reload
43 ; SPILL-O0-NEXT: # implicit-def: $v8
44 ; SPILL-O0-NEXT: vsetvli zero, a0, e64, m1, tu, ma
45 ; SPILL-O0-NEXT: vfadd.vv v8, v9, v10
46 ; SPILL-O0-NEXT: csrr a0, vlenb
47 ; SPILL-O0-NEXT: slli a0, a0, 1
48 ; SPILL-O0-NEXT: add sp, sp, a0
49 ; SPILL-O0-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
50 ; SPILL-O0-NEXT: addi sp, sp, 48
53 ; SPILL-O2-LABEL: foo:
55 ; SPILL-O2-NEXT: addi sp, sp, -32
56 ; SPILL-O2-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
57 ; SPILL-O2-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
58 ; SPILL-O2-NEXT: csrr a1, vlenb
59 ; SPILL-O2-NEXT: slli a1, a1, 1
60 ; SPILL-O2-NEXT: sub sp, sp, a1
61 ; SPILL-O2-NEXT: mv s0, a0
62 ; SPILL-O2-NEXT: addi a1, sp, 16
63 ; SPILL-O2-NEXT: vs1r.v v8, (a1) # Unknown-size Folded Spill
64 ; SPILL-O2-NEXT: vsetvli zero, a0, e64, m1, ta, ma
65 ; SPILL-O2-NEXT: vfadd.vv v9, v8, v9
66 ; SPILL-O2-NEXT: csrr a0, vlenb
67 ; SPILL-O2-NEXT: add a0, sp, a0
68 ; SPILL-O2-NEXT: addi a0, a0, 16
69 ; SPILL-O2-NEXT: vs1r.v v9, (a0) # Unknown-size Folded Spill
70 ; SPILL-O2-NEXT: lui a0, %hi(.L.str)
71 ; SPILL-O2-NEXT: addi a0, a0, %lo(.L.str)
72 ; SPILL-O2-NEXT: call puts
73 ; SPILL-O2-NEXT: csrr a0, vlenb
74 ; SPILL-O2-NEXT: add a0, sp, a0
75 ; SPILL-O2-NEXT: addi a0, a0, 16
76 ; SPILL-O2-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
77 ; SPILL-O2-NEXT: addi a0, sp, 16
78 ; SPILL-O2-NEXT: vl1r.v v9, (a0) # Unknown-size Folded Reload
79 ; SPILL-O2-NEXT: vsetvli zero, s0, e64, m1, ta, ma
80 ; SPILL-O2-NEXT: vfadd.vv v8, v9, v8
81 ; SPILL-O2-NEXT: csrr a0, vlenb
82 ; SPILL-O2-NEXT: slli a0, a0, 1
83 ; SPILL-O2-NEXT: add sp, sp, a0
84 ; SPILL-O2-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
85 ; SPILL-O2-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
86 ; SPILL-O2-NEXT: addi sp, sp, 32
89 ; SPILL-O2-VLEN128-LABEL: foo:
90 ; SPILL-O2-VLEN128: # %bb.0:
91 ; SPILL-O2-VLEN128-NEXT: addi sp, sp, -32
92 ; SPILL-O2-VLEN128-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
93 ; SPILL-O2-VLEN128-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
94 ; SPILL-O2-VLEN128-NEXT: addi sp, sp, -32
95 ; SPILL-O2-VLEN128-NEXT: mv s0, a0
96 ; SPILL-O2-VLEN128-NEXT: addi a1, sp, 16
97 ; SPILL-O2-VLEN128-NEXT: vs1r.v v8, (a1) # Unknown-size Folded Spill
98 ; SPILL-O2-VLEN128-NEXT: vsetvli zero, a0, e64, m1, ta, ma
99 ; SPILL-O2-VLEN128-NEXT: vfadd.vv v9, v8, v9
100 ; SPILL-O2-VLEN128-NEXT: addi a0, sp, 32
101 ; SPILL-O2-VLEN128-NEXT: vs1r.v v9, (a0) # Unknown-size Folded Spill
102 ; SPILL-O2-VLEN128-NEXT: lui a0, %hi(.L.str)
103 ; SPILL-O2-VLEN128-NEXT: addi a0, a0, %lo(.L.str)
104 ; SPILL-O2-VLEN128-NEXT: call puts
105 ; SPILL-O2-VLEN128-NEXT: addi a0, sp, 32
106 ; SPILL-O2-VLEN128-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
107 ; SPILL-O2-VLEN128-NEXT: addi a0, sp, 16
108 ; SPILL-O2-VLEN128-NEXT: vl1r.v v9, (a0) # Unknown-size Folded Reload
109 ; SPILL-O2-VLEN128-NEXT: vsetvli zero, s0, e64, m1, ta, ma
110 ; SPILL-O2-VLEN128-NEXT: vfadd.vv v8, v9, v8
111 ; SPILL-O2-VLEN128-NEXT: addi sp, sp, 32
112 ; SPILL-O2-VLEN128-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
113 ; SPILL-O2-VLEN128-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
114 ; SPILL-O2-VLEN128-NEXT: addi sp, sp, 32
115 ; SPILL-O2-VLEN128-NEXT: ret
117 %x = call <vscale x 1 x double> @llvm.riscv.vfadd.nxv1f64.nxv1f64(<vscale x 1 x double> undef, <vscale x 1 x double> %a, <vscale x 1 x double> %b, i64 7, i64 %gvl)
118 %call = call signext i32 @puts(ptr @.str)
119 %z = call <vscale x 1 x double> @llvm.riscv.vfadd.nxv1f64.nxv1f64(<vscale x 1 x double> undef, <vscale x 1 x double> %a, <vscale x 1 x double> %x, i64 7, i64 %gvl)
120 ret <vscale x 1 x double> %z
123 declare <vscale x 1 x double> @llvm.riscv.vfadd.nxv1f64.nxv1f64(<vscale x 1 x double> %passthru, <vscale x 1 x double> %a, <vscale x 1 x double> %b, i64, i64 %gvl)
124 declare i32 @puts(ptr);