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 ret <vscale x 8 x i64> splat (i64 -1)
16 define <vscale x 8 x i64> @vsplat_nxv8i64_2() {
17 ; CHECK-LABEL: vsplat_nxv8i64_2:
19 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
20 ; CHECK-NEXT: vmv.v.i v8, 4
22 ret <vscale x 8 x i64> splat (i64 4)
25 define <vscale x 8 x i64> @vsplat_nxv8i64_3() {
26 ; CHECK-LABEL: vsplat_nxv8i64_3:
28 ; CHECK-NEXT: li a0, 255
29 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
30 ; CHECK-NEXT: vmv.v.x v8, a0
32 ret <vscale x 8 x i64> splat (i64 255)
35 define <vscale x 8 x i64> @vsplat_nxv8i64_4() {
36 ; RV32V-LABEL: vsplat_nxv8i64_4:
38 ; RV32V-NEXT: addi sp, sp, -16
39 ; RV32V-NEXT: .cfi_def_cfa_offset 16
40 ; RV32V-NEXT: sw zero, 12(sp)
41 ; RV32V-NEXT: lui a0, 1028096
42 ; RV32V-NEXT: addi a0, a0, -1281
43 ; RV32V-NEXT: sw a0, 8(sp)
44 ; RV32V-NEXT: addi a0, sp, 8
45 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
46 ; RV32V-NEXT: vlse64.v v8, (a0), zero
47 ; RV32V-NEXT: addi sp, sp, 16
50 ; RV64V-LABEL: vsplat_nxv8i64_4:
52 ; RV64V-NEXT: li a0, 251
53 ; RV64V-NEXT: slli a0, a0, 24
54 ; RV64V-NEXT: addi a0, a0, -1281
55 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
56 ; RV64V-NEXT: vmv.v.x v8, a0
58 ret <vscale x 8 x i64> splat (i64 4211079935)
61 define <vscale x 8 x i64> @vsplat_nxv8i64_5(i64 %a) {
62 ; RV32V-LABEL: vsplat_nxv8i64_5:
64 ; RV32V-NEXT: addi sp, sp, -16
65 ; RV32V-NEXT: .cfi_def_cfa_offset 16
66 ; RV32V-NEXT: sw a1, 12(sp)
67 ; RV32V-NEXT: sw a0, 8(sp)
68 ; RV32V-NEXT: addi a0, sp, 8
69 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
70 ; RV32V-NEXT: vlse64.v v8, (a0), zero
71 ; RV32V-NEXT: addi sp, sp, 16
74 ; RV64V-LABEL: vsplat_nxv8i64_5:
76 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
77 ; RV64V-NEXT: vmv.v.x v8, a0
79 %head = insertelement <vscale x 8 x i64> poison, i64 %a, i32 0
80 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
81 ret <vscale x 8 x i64> %splat
84 define <vscale x 8 x i64> @vadd_vx_nxv8i64_6(<vscale x 8 x i64> %v) {
85 ; CHECK-LABEL: vadd_vx_nxv8i64_6:
87 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
88 ; CHECK-NEXT: vadd.vi v8, v8, 2
90 %vret = add <vscale x 8 x i64> %v, splat (i64 2)
91 ret <vscale x 8 x i64> %vret
94 define <vscale x 8 x i64> @vadd_vx_nxv8i64_7(<vscale x 8 x i64> %v) {
95 ; CHECK-LABEL: vadd_vx_nxv8i64_7:
97 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
98 ; CHECK-NEXT: vadd.vi v8, v8, -1
100 %vret = add <vscale x 8 x i64> %v, splat (i64 -1)
101 ret <vscale x 8 x i64> %vret
104 define <vscale x 8 x i64> @vadd_vx_nxv8i64_8(<vscale x 8 x i64> %v) {
105 ; CHECK-LABEL: vadd_vx_nxv8i64_8:
107 ; CHECK-NEXT: li a0, 255
108 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
109 ; CHECK-NEXT: vadd.vx v8, v8, a0
111 %vret = add <vscale x 8 x i64> %v, splat (i64 255)
112 ret <vscale x 8 x i64> %vret
115 define <vscale x 8 x i64> @vadd_vx_nxv8i64_9(<vscale x 8 x i64> %v) {
116 ; RV32V-LABEL: vadd_vx_nxv8i64_9:
118 ; RV32V-NEXT: lui a0, 503808
119 ; RV32V-NEXT: addi a0, a0, -1281
120 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
121 ; RV32V-NEXT: vadd.vx v8, v8, a0
124 ; RV64V-LABEL: vadd_vx_nxv8i64_9:
126 ; RV64V-NEXT: lui a0, 503808
127 ; RV64V-NEXT: addiw a0, a0, -1281
128 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
129 ; RV64V-NEXT: vadd.vx v8, v8, a0
131 %vret = add <vscale x 8 x i64> %v, splat (i64 2063596287)
132 ret <vscale x 8 x i64> %vret
135 define <vscale x 8 x i64> @vadd_vx_nxv8i64_10(<vscale x 8 x i64> %v) {
136 ; RV32V-LABEL: vadd_vx_nxv8i64_10:
138 ; RV32V-NEXT: addi sp, sp, -16
139 ; RV32V-NEXT: .cfi_def_cfa_offset 16
140 ; RV32V-NEXT: sw zero, 12(sp)
141 ; RV32V-NEXT: lui a0, 1028096
142 ; RV32V-NEXT: addi a0, a0, -1281
143 ; RV32V-NEXT: sw a0, 8(sp)
144 ; RV32V-NEXT: addi a0, sp, 8
145 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
146 ; RV32V-NEXT: vlse64.v v16, (a0), zero
147 ; RV32V-NEXT: vadd.vv v8, v8, v16
148 ; RV32V-NEXT: addi sp, sp, 16
151 ; RV64V-LABEL: vadd_vx_nxv8i64_10:
153 ; RV64V-NEXT: li a0, 251
154 ; RV64V-NEXT: slli a0, a0, 24
155 ; RV64V-NEXT: addi a0, a0, -1281
156 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
157 ; RV64V-NEXT: vadd.vx v8, v8, a0
159 %vret = add <vscale x 8 x i64> %v, splat (i64 4211079935)
160 ret <vscale x 8 x i64> %vret
163 define <vscale x 8 x i64> @vadd_vx_nxv8i64_11(<vscale x 8 x i64> %v) {
164 ; RV32V-LABEL: vadd_vx_nxv8i64_11:
166 ; RV32V-NEXT: addi sp, sp, -16
167 ; RV32V-NEXT: .cfi_def_cfa_offset 16
168 ; RV32V-NEXT: li a0, 1
169 ; RV32V-NEXT: sw a0, 12(sp)
170 ; RV32V-NEXT: lui a0, 1028096
171 ; RV32V-NEXT: addi a0, a0, -1281
172 ; RV32V-NEXT: sw a0, 8(sp)
173 ; RV32V-NEXT: addi a0, sp, 8
174 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
175 ; RV32V-NEXT: vlse64.v v16, (a0), zero
176 ; RV32V-NEXT: vadd.vv v8, v8, v16
177 ; RV32V-NEXT: addi sp, sp, 16
180 ; RV64V-LABEL: vadd_vx_nxv8i64_11:
182 ; RV64V-NEXT: li a0, 507
183 ; RV64V-NEXT: slli a0, a0, 24
184 ; RV64V-NEXT: addi a0, a0, -1281
185 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
186 ; RV64V-NEXT: vadd.vx v8, v8, a0
188 %vret = add <vscale x 8 x i64> %v, splat (i64 8506047231)
189 ret <vscale x 8 x i64> %vret
192 define <vscale x 8 x i64> @vadd_vx_nxv8i64_12(<vscale x 8 x i64> %v, i64 %a) {
193 ; RV32V-LABEL: vadd_vx_nxv8i64_12:
195 ; RV32V-NEXT: addi sp, sp, -16
196 ; RV32V-NEXT: .cfi_def_cfa_offset 16
197 ; RV32V-NEXT: sw a1, 12(sp)
198 ; RV32V-NEXT: sw a0, 8(sp)
199 ; RV32V-NEXT: addi a0, sp, 8
200 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
201 ; RV32V-NEXT: vlse64.v v16, (a0), zero
202 ; RV32V-NEXT: vadd.vv v8, v8, v16
203 ; RV32V-NEXT: addi sp, sp, 16
206 ; RV64V-LABEL: vadd_vx_nxv8i64_12:
208 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
209 ; RV64V-NEXT: vadd.vx v8, v8, a0
211 %head = insertelement <vscale x 8 x i64> poison, i64 %a, i32 0
212 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
213 %vret = add <vscale x 8 x i64> %v, %splat
214 ret <vscale x 8 x i64> %vret
217 define <vscale x 8 x i64> @vsplat_nxv8i64_13(i32 %a) {
218 ; RV32V-LABEL: vsplat_nxv8i64_13:
220 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
221 ; RV32V-NEXT: vmv.v.x v8, a0
224 ; RV64V-LABEL: vsplat_nxv8i64_13:
226 ; RV64V-NEXT: sext.w a0, a0
227 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
228 ; RV64V-NEXT: vmv.v.x v8, a0
230 %b = sext i32 %a to i64
231 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
232 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
233 ret <vscale x 8 x i64> %splat
236 define <vscale x 8 x i64> @vsplat_nxv8i64_14(i32 %a) {
237 ; RV32V-LABEL: vsplat_nxv8i64_14:
239 ; RV32V-NEXT: addi sp, sp, -16
240 ; RV32V-NEXT: .cfi_def_cfa_offset 16
241 ; RV32V-NEXT: sw zero, 12(sp)
242 ; RV32V-NEXT: sw a0, 8(sp)
243 ; RV32V-NEXT: addi a0, sp, 8
244 ; RV32V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
245 ; RV32V-NEXT: vlse64.v v8, (a0), zero
246 ; RV32V-NEXT: addi sp, sp, 16
249 ; RV64V-LABEL: vsplat_nxv8i64_14:
251 ; RV64V-NEXT: slli a0, a0, 32
252 ; RV64V-NEXT: srli a0, a0, 32
253 ; RV64V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
254 ; RV64V-NEXT: vmv.v.x v8, a0
256 %b = zext i32 %a to i64
257 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
258 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
259 ret <vscale x 8 x i64> %splat