1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,RV32V
4 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s --check-prefixes=CHECK,RV64V
7 define <vscale x 8 x i64> @vsplat_nxv8i64_1() {
8 ; CHECK-LABEL: vsplat_nxv8i64_1:
10 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
11 ; CHECK-NEXT: vmv.v.i v8, -1
13 %head = insertelement <vscale x 8 x i64> poison, i64 -1, i32 0
14 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
15 ret <vscale x 8 x i64> %splat
18 define <vscale x 8 x i64> @vsplat_nxv8i64_2() {
19 ; CHECK-LABEL: vsplat_nxv8i64_2:
21 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
22 ; CHECK-NEXT: vmv.v.i v8, 4
24 %head = insertelement <vscale x 8 x i64> poison, i64 4, i32 0
25 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
26 ret <vscale x 8 x i64> %splat
29 define <vscale x 8 x i64> @vsplat_nxv8i64_3() {
30 ; CHECK-LABEL: vsplat_nxv8i64_3:
32 ; CHECK-NEXT: li a0, 255
33 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
34 ; CHECK-NEXT: vmv.v.x v8, a0
36 %head = insertelement <vscale x 8 x i64> poison, i64 255, i32 0
37 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
38 ret <vscale x 8 x i64> %splat
41 define <vscale x 8 x i64> @vsplat_nxv8i64_4() {
42 ; RV32V-LABEL: vsplat_nxv8i64_4:
44 ; RV32V-NEXT: addi sp, sp, -16
45 ; RV32V-NEXT: .cfi_def_cfa_offset 16
46 ; RV32V-NEXT: sw zero, 12(sp)
47 ; RV32V-NEXT: lui a0, 1028096
48 ; RV32V-NEXT: addi a0, a0, -1281
49 ; RV32V-NEXT: sw a0, 8(sp)
50 ; RV32V-NEXT: addi a0, sp, 8
51 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
52 ; RV32V-NEXT: vlse64.v v8, (a0), zero
53 ; RV32V-NEXT: addi sp, sp, 16
56 ; RV64V-LABEL: vsplat_nxv8i64_4:
58 ; RV64V-NEXT: li a0, 251
59 ; RV64V-NEXT: slli a0, a0, 24
60 ; RV64V-NEXT: addi a0, a0, -1281
61 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
62 ; RV64V-NEXT: vmv.v.x v8, a0
64 %head = insertelement <vscale x 8 x i64> poison, i64 4211079935, i32 0
65 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
66 ret <vscale x 8 x i64> %splat
69 define <vscale x 8 x i64> @vsplat_nxv8i64_5(i64 %a) {
70 ; RV32V-LABEL: vsplat_nxv8i64_5:
72 ; RV32V-NEXT: addi sp, sp, -16
73 ; RV32V-NEXT: .cfi_def_cfa_offset 16
74 ; RV32V-NEXT: sw a1, 12(sp)
75 ; RV32V-NEXT: sw a0, 8(sp)
76 ; RV32V-NEXT: addi a0, sp, 8
77 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
78 ; RV32V-NEXT: vlse64.v v8, (a0), zero
79 ; RV32V-NEXT: addi sp, sp, 16
82 ; RV64V-LABEL: vsplat_nxv8i64_5:
84 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
85 ; RV64V-NEXT: vmv.v.x v8, a0
87 %head = insertelement <vscale x 8 x i64> poison, i64 %a, i32 0
88 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
89 ret <vscale x 8 x i64> %splat
92 define <vscale x 8 x i64> @vadd_vx_nxv8i64_6(<vscale x 8 x i64> %v) {
93 ; CHECK-LABEL: vadd_vx_nxv8i64_6:
95 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
96 ; CHECK-NEXT: vadd.vi v8, v8, 2
98 %head = insertelement <vscale x 8 x i64> poison, i64 2, i32 0
99 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
100 %vret = add <vscale x 8 x i64> %v, %splat
101 ret <vscale x 8 x i64> %vret
104 define <vscale x 8 x i64> @vadd_vx_nxv8i64_7(<vscale x 8 x i64> %v) {
105 ; CHECK-LABEL: vadd_vx_nxv8i64_7:
107 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
108 ; CHECK-NEXT: vadd.vi v8, v8, -1
110 %head = insertelement <vscale x 8 x i64> poison, i64 -1, i32 0
111 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
112 %vret = add <vscale x 8 x i64> %v, %splat
113 ret <vscale x 8 x i64> %vret
116 define <vscale x 8 x i64> @vadd_vx_nxv8i64_8(<vscale x 8 x i64> %v) {
117 ; CHECK-LABEL: vadd_vx_nxv8i64_8:
119 ; CHECK-NEXT: li a0, 255
120 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
121 ; CHECK-NEXT: vadd.vx v8, v8, a0
123 %head = insertelement <vscale x 8 x i64> poison, i64 255, i32 0
124 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
125 %vret = add <vscale x 8 x i64> %v, %splat
126 ret <vscale x 8 x i64> %vret
129 define <vscale x 8 x i64> @vadd_vx_nxv8i64_9(<vscale x 8 x i64> %v) {
130 ; RV32V-LABEL: vadd_vx_nxv8i64_9:
132 ; RV32V-NEXT: lui a0, 503808
133 ; RV32V-NEXT: addi a0, a0, -1281
134 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
135 ; RV32V-NEXT: vadd.vx v8, v8, a0
138 ; RV64V-LABEL: vadd_vx_nxv8i64_9:
140 ; RV64V-NEXT: lui a0, 503808
141 ; RV64V-NEXT: addiw a0, a0, -1281
142 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
143 ; RV64V-NEXT: vadd.vx v8, v8, a0
145 %head = insertelement <vscale x 8 x i64> poison, i64 2063596287, i32 0
146 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
147 %vret = add <vscale x 8 x i64> %v, %splat
148 ret <vscale x 8 x i64> %vret
151 define <vscale x 8 x i64> @vadd_vx_nxv8i64_10(<vscale x 8 x i64> %v) {
152 ; RV32V-LABEL: vadd_vx_nxv8i64_10:
154 ; RV32V-NEXT: addi sp, sp, -16
155 ; RV32V-NEXT: .cfi_def_cfa_offset 16
156 ; RV32V-NEXT: sw zero, 12(sp)
157 ; RV32V-NEXT: lui a0, 1028096
158 ; RV32V-NEXT: addi a0, a0, -1281
159 ; RV32V-NEXT: sw a0, 8(sp)
160 ; RV32V-NEXT: addi a0, sp, 8
161 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
162 ; RV32V-NEXT: vlse64.v v16, (a0), zero
163 ; RV32V-NEXT: vadd.vv v8, v8, v16
164 ; RV32V-NEXT: addi sp, sp, 16
167 ; RV64V-LABEL: vadd_vx_nxv8i64_10:
169 ; RV64V-NEXT: li a0, 251
170 ; RV64V-NEXT: slli a0, a0, 24
171 ; RV64V-NEXT: addi a0, a0, -1281
172 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
173 ; RV64V-NEXT: vadd.vx v8, v8, a0
175 %head = insertelement <vscale x 8 x i64> poison, i64 4211079935, i32 0
176 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
177 %vret = add <vscale x 8 x i64> %v, %splat
178 ret <vscale x 8 x i64> %vret
181 define <vscale x 8 x i64> @vadd_vx_nxv8i64_11(<vscale x 8 x i64> %v) {
182 ; RV32V-LABEL: vadd_vx_nxv8i64_11:
184 ; RV32V-NEXT: addi sp, sp, -16
185 ; RV32V-NEXT: .cfi_def_cfa_offset 16
186 ; RV32V-NEXT: li a0, 1
187 ; RV32V-NEXT: sw a0, 12(sp)
188 ; RV32V-NEXT: lui a0, 1028096
189 ; RV32V-NEXT: addi a0, a0, -1281
190 ; RV32V-NEXT: sw a0, 8(sp)
191 ; RV32V-NEXT: addi a0, sp, 8
192 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
193 ; RV32V-NEXT: vlse64.v v16, (a0), zero
194 ; RV32V-NEXT: vadd.vv v8, v8, v16
195 ; RV32V-NEXT: addi sp, sp, 16
198 ; RV64V-LABEL: vadd_vx_nxv8i64_11:
200 ; RV64V-NEXT: li a0, 507
201 ; RV64V-NEXT: slli a0, a0, 24
202 ; RV64V-NEXT: addi a0, a0, -1281
203 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
204 ; RV64V-NEXT: vadd.vx v8, v8, a0
206 %head = insertelement <vscale x 8 x i64> poison, i64 8506047231, i32 0
207 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
208 %vret = add <vscale x 8 x i64> %v, %splat
209 ret <vscale x 8 x i64> %vret
212 define <vscale x 8 x i64> @vadd_vx_nxv8i64_12(<vscale x 8 x i64> %v, i64 %a) {
213 ; RV32V-LABEL: vadd_vx_nxv8i64_12:
215 ; RV32V-NEXT: addi sp, sp, -16
216 ; RV32V-NEXT: .cfi_def_cfa_offset 16
217 ; RV32V-NEXT: sw a1, 12(sp)
218 ; RV32V-NEXT: sw a0, 8(sp)
219 ; RV32V-NEXT: addi a0, sp, 8
220 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
221 ; RV32V-NEXT: vlse64.v v16, (a0), zero
222 ; RV32V-NEXT: vadd.vv v8, v8, v16
223 ; RV32V-NEXT: addi sp, sp, 16
226 ; RV64V-LABEL: vadd_vx_nxv8i64_12:
228 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
229 ; RV64V-NEXT: vadd.vx v8, v8, a0
231 %head = insertelement <vscale x 8 x i64> poison, i64 %a, i32 0
232 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
233 %vret = add <vscale x 8 x i64> %v, %splat
234 ret <vscale x 8 x i64> %vret
237 define <vscale x 8 x i64> @vsplat_nxv8i64_13(i32 %a) {
238 ; RV32V-LABEL: vsplat_nxv8i64_13:
240 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
241 ; RV32V-NEXT: vmv.v.x v8, a0
244 ; RV64V-LABEL: vsplat_nxv8i64_13:
246 ; RV64V-NEXT: sext.w a0, a0
247 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
248 ; RV64V-NEXT: vmv.v.x v8, a0
250 %b = sext i32 %a to i64
251 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
252 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
253 ret <vscale x 8 x i64> %splat
256 define <vscale x 8 x i64> @vsplat_nxv8i64_14(i32 %a) {
257 ; RV32V-LABEL: vsplat_nxv8i64_14:
259 ; RV32V-NEXT: addi sp, sp, -16
260 ; RV32V-NEXT: .cfi_def_cfa_offset 16
261 ; RV32V-NEXT: sw zero, 12(sp)
262 ; RV32V-NEXT: sw a0, 8(sp)
263 ; RV32V-NEXT: addi a0, sp, 8
264 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
265 ; RV32V-NEXT: vlse64.v v8, (a0), zero
266 ; RV32V-NEXT: addi sp, sp, 16
269 ; RV64V-LABEL: vsplat_nxv8i64_14:
271 ; RV64V-NEXT: slli a0, a0, 32
272 ; RV64V-NEXT: srli a0, a0, 32
273 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
274 ; RV64V-NEXT: vmv.v.x v8, a0
276 %b = zext i32 %a to i64
277 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
278 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
279 ret <vscale x 8 x i64> %splat