1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O3 -mtriple=riscv64 -mattr=+v < %s | FileCheck %s
4 define void @constant_splat_fixed(ptr %p) {
5 ; CHECK-LABEL: constant_splat_fixed:
7 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
8 ; CHECK-NEXT: vmv.v.i v8, 0
9 ; CHECK-NEXT: vse32.v v8, (a0)
11 store <4 x i32> zeroinitializer, ptr %p
15 define void @constant_splat_scalable(ptr %p) {
16 ; CHECK-LABEL: constant_splat_scalable:
18 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
19 ; CHECK-NEXT: vmv.v.i v8, 0
20 ; CHECK-NEXT: vse32.v v8, (a0)
22 store <vscale x 1 x i32> zeroinitializer, ptr %p
26 ; FIXME: We should be able to use the earlier splat of zero here
28 define void @constant_splat_scalable_then_fixed(ptr %p, ptr %p2) {
29 ; CHECK-LABEL: constant_splat_scalable_then_fixed:
31 ; CHECK-NEXT: vsetvli a2, zero, e32, mf2, ta, ma
32 ; CHECK-NEXT: vmv.v.i v8, 0
33 ; CHECK-NEXT: vse32.v v8, (a0)
34 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
35 ; CHECK-NEXT: vmv.v.i v8, 0
36 ; CHECK-NEXT: vse32.v v8, (a1)
38 store <vscale x 1 x i32> zeroinitializer, ptr %p
39 store <4 x i32> zeroinitializer, ptr %p2
43 ; We could widen the first splat to VLMAX, but this might not
44 ; be generally profitable.
45 define void @constant_splat_fixed_then_scalable(ptr %p, ptr %p2) {
46 ; CHECK-LABEL: constant_splat_fixed_then_scalable:
48 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
49 ; CHECK-NEXT: vmv.v.i v8, 0
50 ; CHECK-NEXT: vse32.v v8, (a1)
51 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
52 ; CHECK-NEXT: vmv.v.i v8, 0
53 ; CHECK-NEXT: vse32.v v8, (a0)
55 store <4 x i32> zeroinitializer, ptr %p2
56 store <vscale x 1 x i32> zeroinitializer, ptr %p
60 define void @splat_scalable(ptr %p, i32 %v) {
61 ; CHECK-LABEL: splat_scalable:
63 ; CHECK-NEXT: vsetvli a2, zero, e32, mf2, ta, ma
64 ; CHECK-NEXT: vmv.v.x v8, a1
65 ; CHECK-NEXT: vse32.v v8, (a0)
67 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
68 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
69 store <vscale x 1 x i32> %splat, ptr %p
73 define void @splat_fixed(ptr %p, i32 %v) {
74 ; CHECK-LABEL: splat_fixed:
76 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
77 ; CHECK-NEXT: vmv.v.x v8, a1
78 ; CHECK-NEXT: vse32.v v8, (a0)
80 %elt.head = insertelement <4 x i32> poison, i32 %v, i32 0
81 %splat = shufflevector <4 x i32> %elt.head, <4 x i32> poison, <4 x i32> zeroinitializer
82 store <4 x i32> %splat, ptr %p
86 ; FIXME: We should reschedule the first splat to reduce the need
88 define void @mixed_splats1(ptr %p, i32 %v) {
89 ; CHECK-LABEL: mixed_splats1:
91 ; CHECK-NEXT: vsetvli a2, zero, e32, mf2, ta, ma
92 ; CHECK-NEXT: vmv.v.x v8, a1
93 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
94 ; CHECK-NEXT: vmv.v.i v9, 0
95 ; CHECK-NEXT: vse32.v v9, (a0)
96 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
97 ; CHECK-NEXT: vse32.v v8, (a0)
99 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
100 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
102 store <4 x i32> zeroinitializer, ptr %p
103 store <vscale x 1 x i32> %splat, ptr %p
107 define void @mixed_splats2(ptr %p, i32 %v) {
108 ; CHECK-LABEL: mixed_splats2:
110 ; CHECK-NEXT: vsetvli a2, zero, e32, mf2, ta, ma
111 ; CHECK-NEXT: vmv.v.x v8, a1
112 ; CHECK-NEXT: vse32.v v8, (a0)
113 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
114 ; CHECK-NEXT: vmv.v.i v8, 0
115 ; CHECK-NEXT: vse32.v v8, (a0)
117 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
118 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
120 store <vscale x 1 x i32> %splat, ptr %p
121 store <4 x i32> zeroinitializer, ptr %p
125 define void @extract_vector(ptr %p, i32 %v) {
126 ; CHECK-LABEL: extract_vector:
128 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
129 ; CHECK-NEXT: vmv.v.x v8, a1
130 ; CHECK-NEXT: vse32.v v8, (a0)
132 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
133 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
135 %fv = call <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %splat, i64 0)
136 store <4 x i32> %fv, ptr %p
140 define void @extract_vector_multiuse1(ptr %p, ptr %p2, i32 %v) {
141 ; CHECK-LABEL: extract_vector_multiuse1:
143 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
144 ; CHECK-NEXT: vmv.v.x v8, a2
145 ; CHECK-NEXT: vse32.v v8, (a0)
146 ; CHECK-NEXT: vse32.v v8, (a1)
148 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
149 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
151 %fv = call <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %splat, i64 0)
152 store <4 x i32> %fv, ptr %p
153 store <4 x i32> %fv, ptr %p2
157 define <vscale x 1 x i32> @extract_vector_multiuse2(ptr %p, ptr %p2, i32 %v) {
158 ; CHECK-LABEL: extract_vector_multiuse2:
160 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
161 ; CHECK-NEXT: vmv.v.x v8, a2
162 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
163 ; CHECK-NEXT: vse32.v v8, (a0)
165 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
166 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
168 %fv = call <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %splat, i64 0)
169 store <4 x i32> %fv, ptr %p
170 ret <vscale x 1 x i32> %splat
173 define void @extract_vector_mixed1(ptr %p, ptr %p2, i32 %v) {
174 ; CHECK-LABEL: extract_vector_mixed1:
176 ; CHECK-NEXT: vsetvli a3, zero, e32, mf2, ta, ma
177 ; CHECK-NEXT: vmv.v.x v8, a2
178 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
179 ; CHECK-NEXT: vse32.v v8, (a0)
180 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
181 ; CHECK-NEXT: vse32.v v8, (a1)
183 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
184 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
186 %fv = call <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %splat, i64 0)
188 store <4 x i32> %fv, ptr %p
189 store <vscale x 1 x i32> %splat, ptr %p2
193 define void @extract_vector_mixed2(ptr %p, ptr %p2, i32 %v) {
194 ; CHECK-LABEL: extract_vector_mixed2:
196 ; CHECK-NEXT: vsetvli a3, zero, e32, mf2, ta, ma
197 ; CHECK-NEXT: vmv.v.x v8, a2
198 ; CHECK-NEXT: vse32.v v8, (a0)
199 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
200 ; CHECK-NEXT: vse32.v v8, (a1)
202 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
203 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
204 store <vscale x 1 x i32> %splat, ptr %p
206 %fv = call <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %splat, i64 0)
207 store <4 x i32> %fv, ptr %p2
211 define void @extract_vector_mixed3(ptr %p, ptr %p2, i32 %v) {
212 ; CHECK-LABEL: extract_vector_mixed3:
214 ; CHECK-NEXT: vsetvli a3, zero, e32, mf2, ta, ma
215 ; CHECK-NEXT: vmv.v.x v8, a2
216 ; CHECK-NEXT: vse32.v v8, (a0)
217 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
218 ; CHECK-NEXT: vse32.v v8, (a1)
220 %elt.head = insertelement <vscale x 1 x i32> poison, i32 %v, i32 0
221 %splat = shufflevector <vscale x 1 x i32> %elt.head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
222 %fv = call <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %splat, i64 0)
224 store <vscale x 1 x i32> %splat, ptr %p
225 store <4 x i32> %fv, ptr %p2
230 declare <4 x i32> @llvm.vector.extract.v4i32.nxv1132(<vscale x 1 x i32> %vec, i64 %idx)