1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
5 define <vscale x 1 x i8> @vsub_vv_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb) {
6 ; CHECK-LABEL: vsub_vv_nxv1i8:
8 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
9 ; CHECK-NEXT: vsub.vv v8, v8, v9
11 %vc = sub <vscale x 1 x i8> %va, %vb
12 ret <vscale x 1 x i8> %vc
15 define <vscale x 1 x i8> @vsub_vx_nxv1i8(<vscale x 1 x i8> %va, i8 signext %b) {
16 ; CHECK-LABEL: vsub_vx_nxv1i8:
18 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
19 ; CHECK-NEXT: vsub.vx v8, v8, a0
21 %head = insertelement <vscale x 1 x i8> poison, i8 %b, i32 0
22 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> poison, <vscale x 1 x i32> zeroinitializer
23 %vc = sub <vscale x 1 x i8> %va, %splat
24 ret <vscale x 1 x i8> %vc
27 define <vscale x 1 x i8> @vsub_vx_nxv1i8_0(<vscale x 1 x i8> %va) {
28 ; CHECK-LABEL: vsub_vx_nxv1i8_0:
30 ; CHECK-NEXT: li a0, 1
31 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
32 ; CHECK-NEXT: vsub.vx v8, v8, a0
34 %vc = sub <vscale x 1 x i8> %va, splat (i8 1)
35 ret <vscale x 1 x i8> %vc
38 ; Test constant subs to see if we can optimize them away for scalable vectors.
39 define <vscale x 1 x i8> @vsub_ii_nxv1i8_1() {
40 ; CHECK-LABEL: vsub_ii_nxv1i8_1:
42 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
43 ; CHECK-NEXT: vmv.v.i v8, -1
45 %vc = sub <vscale x 1 x i8> splat (i8 2), splat (i8 3)
46 ret <vscale x 1 x i8> %vc
49 define <vscale x 2 x i8> @vsub_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
50 ; CHECK-LABEL: vsub_vv_nxv2i8:
52 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
53 ; CHECK-NEXT: vsub.vv v8, v8, v9
55 %vc = sub <vscale x 2 x i8> %va, %vb
56 ret <vscale x 2 x i8> %vc
59 define <vscale x 2 x i8> @vsub_vx_nxv2i8(<vscale x 2 x i8> %va, i8 signext %b) {
60 ; CHECK-LABEL: vsub_vx_nxv2i8:
62 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
63 ; CHECK-NEXT: vsub.vx v8, v8, a0
65 %head = insertelement <vscale x 2 x i8> poison, i8 %b, i32 0
66 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
67 %vc = sub <vscale x 2 x i8> %va, %splat
68 ret <vscale x 2 x i8> %vc
71 define <vscale x 2 x i8> @vsub_vx_nxv2i8_0(<vscale x 2 x i8> %va) {
72 ; CHECK-LABEL: vsub_vx_nxv2i8_0:
74 ; CHECK-NEXT: li a0, 1
75 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
76 ; CHECK-NEXT: vsub.vx v8, v8, a0
78 %vc = sub <vscale x 2 x i8> %va, splat (i8 1)
79 ret <vscale x 2 x i8> %vc
82 define <vscale x 4 x i8> @vsub_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
83 ; CHECK-LABEL: vsub_vv_nxv4i8:
85 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
86 ; CHECK-NEXT: vsub.vv v8, v8, v9
88 %vc = sub <vscale x 4 x i8> %va, %vb
89 ret <vscale x 4 x i8> %vc
92 define <vscale x 4 x i8> @vsub_vx_nxv4i8(<vscale x 4 x i8> %va, i8 signext %b) {
93 ; CHECK-LABEL: vsub_vx_nxv4i8:
95 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
96 ; CHECK-NEXT: vsub.vx v8, v8, a0
98 %head = insertelement <vscale x 4 x i8> poison, i8 %b, i32 0
99 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
100 %vc = sub <vscale x 4 x i8> %va, %splat
101 ret <vscale x 4 x i8> %vc
104 define <vscale x 4 x i8> @vsub_vx_nxv4i8_0(<vscale x 4 x i8> %va) {
105 ; CHECK-LABEL: vsub_vx_nxv4i8_0:
107 ; CHECK-NEXT: li a0, 1
108 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
109 ; CHECK-NEXT: vsub.vx v8, v8, a0
111 %vc = sub <vscale x 4 x i8> %va, splat (i8 1)
112 ret <vscale x 4 x i8> %vc
115 define <vscale x 8 x i8> @vsub_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
116 ; CHECK-LABEL: vsub_vv_nxv8i8:
118 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
119 ; CHECK-NEXT: vsub.vv v8, v8, v9
121 %vc = sub <vscale x 8 x i8> %va, %vb
122 ret <vscale x 8 x i8> %vc
125 define <vscale x 8 x i8> @vsub_vx_nxv8i8(<vscale x 8 x i8> %va, i8 signext %b) {
126 ; CHECK-LABEL: vsub_vx_nxv8i8:
128 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
129 ; CHECK-NEXT: vsub.vx v8, v8, a0
131 %head = insertelement <vscale x 8 x i8> poison, i8 %b, i32 0
132 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
133 %vc = sub <vscale x 8 x i8> %va, %splat
134 ret <vscale x 8 x i8> %vc
137 define <vscale x 8 x i8> @vsub_vx_nxv8i8_0(<vscale x 8 x i8> %va) {
138 ; CHECK-LABEL: vsub_vx_nxv8i8_0:
140 ; CHECK-NEXT: li a0, 1
141 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
142 ; CHECK-NEXT: vsub.vx v8, v8, a0
144 %vc = sub <vscale x 8 x i8> %va, splat (i8 1)
145 ret <vscale x 8 x i8> %vc
148 define <vscale x 16 x i8> @vsub_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
149 ; CHECK-LABEL: vsub_vv_nxv16i8:
151 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
152 ; CHECK-NEXT: vsub.vv v8, v8, v10
154 %vc = sub <vscale x 16 x i8> %va, %vb
155 ret <vscale x 16 x i8> %vc
158 define <vscale x 16 x i8> @vsub_vx_nxv16i8(<vscale x 16 x i8> %va, i8 signext %b) {
159 ; CHECK-LABEL: vsub_vx_nxv16i8:
161 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
162 ; CHECK-NEXT: vsub.vx v8, v8, a0
164 %head = insertelement <vscale x 16 x i8> poison, i8 %b, i32 0
165 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
166 %vc = sub <vscale x 16 x i8> %va, %splat
167 ret <vscale x 16 x i8> %vc
170 define <vscale x 16 x i8> @vsub_vx_nxv16i8_0(<vscale x 16 x i8> %va) {
171 ; CHECK-LABEL: vsub_vx_nxv16i8_0:
173 ; CHECK-NEXT: li a0, 1
174 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
175 ; CHECK-NEXT: vsub.vx v8, v8, a0
177 %vc = sub <vscale x 16 x i8> %va, splat (i8 1)
178 ret <vscale x 16 x i8> %vc
181 define <vscale x 32 x i8> @vsub_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
182 ; CHECK-LABEL: vsub_vv_nxv32i8:
184 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
185 ; CHECK-NEXT: vsub.vv v8, v8, v12
187 %vc = sub <vscale x 32 x i8> %va, %vb
188 ret <vscale x 32 x i8> %vc
191 define <vscale x 32 x i8> @vsub_vx_nxv32i8(<vscale x 32 x i8> %va, i8 signext %b) {
192 ; CHECK-LABEL: vsub_vx_nxv32i8:
194 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
195 ; CHECK-NEXT: vsub.vx v8, v8, a0
197 %head = insertelement <vscale x 32 x i8> poison, i8 %b, i32 0
198 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
199 %vc = sub <vscale x 32 x i8> %va, %splat
200 ret <vscale x 32 x i8> %vc
203 define <vscale x 32 x i8> @vsub_vx_nxv32i8_0(<vscale x 32 x i8> %va) {
204 ; CHECK-LABEL: vsub_vx_nxv32i8_0:
206 ; CHECK-NEXT: li a0, 1
207 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
208 ; CHECK-NEXT: vsub.vx v8, v8, a0
210 %vc = sub <vscale x 32 x i8> %va, splat (i8 1)
211 ret <vscale x 32 x i8> %vc
214 define <vscale x 64 x i8> @vsub_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb) {
215 ; CHECK-LABEL: vsub_vv_nxv64i8:
217 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
218 ; CHECK-NEXT: vsub.vv v8, v8, v16
220 %vc = sub <vscale x 64 x i8> %va, %vb
221 ret <vscale x 64 x i8> %vc
224 define <vscale x 64 x i8> @vsub_vx_nxv64i8(<vscale x 64 x i8> %va, i8 signext %b) {
225 ; CHECK-LABEL: vsub_vx_nxv64i8:
227 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
228 ; CHECK-NEXT: vsub.vx v8, v8, a0
230 %head = insertelement <vscale x 64 x i8> poison, i8 %b, i32 0
231 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
232 %vc = sub <vscale x 64 x i8> %va, %splat
233 ret <vscale x 64 x i8> %vc
236 define <vscale x 64 x i8> @vsub_vx_nxv64i8_0(<vscale x 64 x i8> %va) {
237 ; CHECK-LABEL: vsub_vx_nxv64i8_0:
239 ; CHECK-NEXT: li a0, 1
240 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
241 ; CHECK-NEXT: vsub.vx v8, v8, a0
243 %vc = sub <vscale x 64 x i8> %va, splat (i8 1)
244 ret <vscale x 64 x i8> %vc
247 define <vscale x 1 x i16> @vsub_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
248 ; CHECK-LABEL: vsub_vv_nxv1i16:
250 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
251 ; CHECK-NEXT: vsub.vv v8, v8, v9
253 %vc = sub <vscale x 1 x i16> %va, %vb
254 ret <vscale x 1 x i16> %vc
257 define <vscale x 1 x i16> @vsub_vx_nxv1i16(<vscale x 1 x i16> %va, i16 signext %b) {
258 ; CHECK-LABEL: vsub_vx_nxv1i16:
260 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
261 ; CHECK-NEXT: vsub.vx v8, v8, a0
263 %head = insertelement <vscale x 1 x i16> poison, i16 %b, i32 0
264 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
265 %vc = sub <vscale x 1 x i16> %va, %splat
266 ret <vscale x 1 x i16> %vc
269 define <vscale x 1 x i16> @vsub_vx_nxv1i16_0(<vscale x 1 x i16> %va) {
270 ; CHECK-LABEL: vsub_vx_nxv1i16_0:
272 ; CHECK-NEXT: li a0, 1
273 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
274 ; CHECK-NEXT: vsub.vx v8, v8, a0
276 %vc = sub <vscale x 1 x i16> %va, splat (i16 1)
277 ret <vscale x 1 x i16> %vc
280 define <vscale x 2 x i16> @vsub_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
281 ; CHECK-LABEL: vsub_vv_nxv2i16:
283 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
284 ; CHECK-NEXT: vsub.vv v8, v8, v9
286 %vc = sub <vscale x 2 x i16> %va, %vb
287 ret <vscale x 2 x i16> %vc
290 define <vscale x 2 x i16> @vsub_vx_nxv2i16(<vscale x 2 x i16> %va, i16 signext %b) {
291 ; CHECK-LABEL: vsub_vx_nxv2i16:
293 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
294 ; CHECK-NEXT: vsub.vx v8, v8, a0
296 %head = insertelement <vscale x 2 x i16> poison, i16 %b, i32 0
297 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
298 %vc = sub <vscale x 2 x i16> %va, %splat
299 ret <vscale x 2 x i16> %vc
302 define <vscale x 2 x i16> @vsub_vx_nxv2i16_0(<vscale x 2 x i16> %va) {
303 ; CHECK-LABEL: vsub_vx_nxv2i16_0:
305 ; CHECK-NEXT: li a0, 1
306 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
307 ; CHECK-NEXT: vsub.vx v8, v8, a0
309 %vc = sub <vscale x 2 x i16> %va, splat (i16 1)
310 ret <vscale x 2 x i16> %vc
313 define <vscale x 4 x i16> @vsub_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
314 ; CHECK-LABEL: vsub_vv_nxv4i16:
316 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
317 ; CHECK-NEXT: vsub.vv v8, v8, v9
319 %vc = sub <vscale x 4 x i16> %va, %vb
320 ret <vscale x 4 x i16> %vc
323 define <vscale x 4 x i16> @vsub_vx_nxv4i16(<vscale x 4 x i16> %va, i16 signext %b) {
324 ; CHECK-LABEL: vsub_vx_nxv4i16:
326 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
327 ; CHECK-NEXT: vsub.vx v8, v8, a0
329 %head = insertelement <vscale x 4 x i16> poison, i16 %b, i32 0
330 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
331 %vc = sub <vscale x 4 x i16> %va, %splat
332 ret <vscale x 4 x i16> %vc
335 define <vscale x 4 x i16> @vsub_vx_nxv4i16_0(<vscale x 4 x i16> %va) {
336 ; CHECK-LABEL: vsub_vx_nxv4i16_0:
338 ; CHECK-NEXT: li a0, 1
339 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
340 ; CHECK-NEXT: vsub.vx v8, v8, a0
342 %vc = sub <vscale x 4 x i16> %va, splat (i16 1)
343 ret <vscale x 4 x i16> %vc
346 define <vscale x 8 x i16> @vsub_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
347 ; CHECK-LABEL: vsub_vv_nxv8i16:
349 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
350 ; CHECK-NEXT: vsub.vv v8, v8, v10
352 %vc = sub <vscale x 8 x i16> %va, %vb
353 ret <vscale x 8 x i16> %vc
356 define <vscale x 8 x i16> @vsub_vx_nxv8i16(<vscale x 8 x i16> %va, i16 signext %b) {
357 ; CHECK-LABEL: vsub_vx_nxv8i16:
359 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
360 ; CHECK-NEXT: vsub.vx v8, v8, a0
362 %head = insertelement <vscale x 8 x i16> poison, i16 %b, i32 0
363 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
364 %vc = sub <vscale x 8 x i16> %va, %splat
365 ret <vscale x 8 x i16> %vc
368 define <vscale x 8 x i16> @vsub_vx_nxv8i16_0(<vscale x 8 x i16> %va) {
369 ; CHECK-LABEL: vsub_vx_nxv8i16_0:
371 ; CHECK-NEXT: li a0, 1
372 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
373 ; CHECK-NEXT: vsub.vx v8, v8, a0
375 %vc = sub <vscale x 8 x i16> %va, splat (i16 1)
376 ret <vscale x 8 x i16> %vc
379 define <vscale x 16 x i16> @vsub_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
380 ; CHECK-LABEL: vsub_vv_nxv16i16:
382 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
383 ; CHECK-NEXT: vsub.vv v8, v8, v12
385 %vc = sub <vscale x 16 x i16> %va, %vb
386 ret <vscale x 16 x i16> %vc
389 define <vscale x 16 x i16> @vsub_vx_nxv16i16(<vscale x 16 x i16> %va, i16 signext %b) {
390 ; CHECK-LABEL: vsub_vx_nxv16i16:
392 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
393 ; CHECK-NEXT: vsub.vx v8, v8, a0
395 %head = insertelement <vscale x 16 x i16> poison, i16 %b, i32 0
396 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
397 %vc = sub <vscale x 16 x i16> %va, %splat
398 ret <vscale x 16 x i16> %vc
401 define <vscale x 16 x i16> @vsub_vx_nxv16i16_0(<vscale x 16 x i16> %va) {
402 ; CHECK-LABEL: vsub_vx_nxv16i16_0:
404 ; CHECK-NEXT: li a0, 1
405 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
406 ; CHECK-NEXT: vsub.vx v8, v8, a0
408 %vc = sub <vscale x 16 x i16> %va, splat (i16 1)
409 ret <vscale x 16 x i16> %vc
412 define <vscale x 32 x i16> @vsub_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb) {
413 ; CHECK-LABEL: vsub_vv_nxv32i16:
415 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
416 ; CHECK-NEXT: vsub.vv v8, v8, v16
418 %vc = sub <vscale x 32 x i16> %va, %vb
419 ret <vscale x 32 x i16> %vc
422 define <vscale x 32 x i16> @vsub_vx_nxv32i16(<vscale x 32 x i16> %va, i16 signext %b) {
423 ; CHECK-LABEL: vsub_vx_nxv32i16:
425 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
426 ; CHECK-NEXT: vsub.vx v8, v8, a0
428 %head = insertelement <vscale x 32 x i16> poison, i16 %b, i32 0
429 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
430 %vc = sub <vscale x 32 x i16> %va, %splat
431 ret <vscale x 32 x i16> %vc
434 define <vscale x 32 x i16> @vsub_vx_nxv32i16_0(<vscale x 32 x i16> %va) {
435 ; CHECK-LABEL: vsub_vx_nxv32i16_0:
437 ; CHECK-NEXT: li a0, 1
438 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
439 ; CHECK-NEXT: vsub.vx v8, v8, a0
441 %vc = sub <vscale x 32 x i16> %va, splat (i16 1)
442 ret <vscale x 32 x i16> %vc
445 define <vscale x 1 x i32> @vsub_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb) {
446 ; CHECK-LABEL: vsub_vv_nxv1i32:
448 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
449 ; CHECK-NEXT: vsub.vv v8, v8, v9
451 %vc = sub <vscale x 1 x i32> %va, %vb
452 ret <vscale x 1 x i32> %vc
455 define <vscale x 1 x i32> @vsub_vx_nxv1i32(<vscale x 1 x i32> %va, i32 signext %b) {
456 ; CHECK-LABEL: vsub_vx_nxv1i32:
458 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
459 ; CHECK-NEXT: vsub.vx v8, v8, a0
461 %head = insertelement <vscale x 1 x i32> poison, i32 %b, i32 0
462 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
463 %vc = sub <vscale x 1 x i32> %va, %splat
464 ret <vscale x 1 x i32> %vc
467 define <vscale x 1 x i32> @vsub_vx_nxv1i32_0(<vscale x 1 x i32> %va) {
468 ; CHECK-LABEL: vsub_vx_nxv1i32_0:
470 ; CHECK-NEXT: li a0, 1
471 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
472 ; CHECK-NEXT: vsub.vx v8, v8, a0
474 %vc = sub <vscale x 1 x i32> %va, splat (i32 1)
475 ret <vscale x 1 x i32> %vc
478 define <vscale x 2 x i32> @vsub_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb) {
479 ; CHECK-LABEL: vsub_vv_nxv2i32:
481 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
482 ; CHECK-NEXT: vsub.vv v8, v8, v9
484 %vc = sub <vscale x 2 x i32> %va, %vb
485 ret <vscale x 2 x i32> %vc
488 define <vscale x 2 x i32> @vsub_vx_nxv2i32(<vscale x 2 x i32> %va, i32 signext %b) {
489 ; CHECK-LABEL: vsub_vx_nxv2i32:
491 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
492 ; CHECK-NEXT: vsub.vx v8, v8, a0
494 %head = insertelement <vscale x 2 x i32> poison, i32 %b, i32 0
495 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
496 %vc = sub <vscale x 2 x i32> %va, %splat
497 ret <vscale x 2 x i32> %vc
500 define <vscale x 2 x i32> @vsub_vx_nxv2i32_0(<vscale x 2 x i32> %va) {
501 ; CHECK-LABEL: vsub_vx_nxv2i32_0:
503 ; CHECK-NEXT: li a0, 1
504 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
505 ; CHECK-NEXT: vsub.vx v8, v8, a0
507 %vc = sub <vscale x 2 x i32> %va, splat (i32 1)
508 ret <vscale x 2 x i32> %vc
511 define <vscale x 4 x i32> @vsub_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb) {
512 ; CHECK-LABEL: vsub_vv_nxv4i32:
514 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
515 ; CHECK-NEXT: vsub.vv v8, v8, v10
517 %vc = sub <vscale x 4 x i32> %va, %vb
518 ret <vscale x 4 x i32> %vc
521 define <vscale x 4 x i32> @vsub_vx_nxv4i32(<vscale x 4 x i32> %va, i32 signext %b) {
522 ; CHECK-LABEL: vsub_vx_nxv4i32:
524 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
525 ; CHECK-NEXT: vsub.vx v8, v8, a0
527 %head = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
528 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
529 %vc = sub <vscale x 4 x i32> %va, %splat
530 ret <vscale x 4 x i32> %vc
533 define <vscale x 4 x i32> @vsub_vx_nxv4i32_0(<vscale x 4 x i32> %va) {
534 ; CHECK-LABEL: vsub_vx_nxv4i32_0:
536 ; CHECK-NEXT: li a0, 1
537 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
538 ; CHECK-NEXT: vsub.vx v8, v8, a0
540 %vc = sub <vscale x 4 x i32> %va, splat (i32 1)
541 ret <vscale x 4 x i32> %vc
544 define <vscale x 8 x i32> @vsub_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb) {
545 ; CHECK-LABEL: vsub_vv_nxv8i32:
547 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
548 ; CHECK-NEXT: vsub.vv v8, v8, v12
550 %vc = sub <vscale x 8 x i32> %va, %vb
551 ret <vscale x 8 x i32> %vc
554 define <vscale x 8 x i32> @vsub_vx_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b) {
555 ; CHECK-LABEL: vsub_vx_nxv8i32:
557 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
558 ; CHECK-NEXT: vsub.vx v8, v8, a0
560 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
561 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
562 %vc = sub <vscale x 8 x i32> %va, %splat
563 ret <vscale x 8 x i32> %vc
566 define <vscale x 8 x i32> @vsub_vx_nxv8i32_0(<vscale x 8 x i32> %va) {
567 ; CHECK-LABEL: vsub_vx_nxv8i32_0:
569 ; CHECK-NEXT: li a0, 1
570 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
571 ; CHECK-NEXT: vsub.vx v8, v8, a0
573 %vc = sub <vscale x 8 x i32> %va, splat (i32 1)
574 ret <vscale x 8 x i32> %vc
577 define <vscale x 16 x i32> @vsub_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb) {
578 ; CHECK-LABEL: vsub_vv_nxv16i32:
580 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
581 ; CHECK-NEXT: vsub.vv v8, v8, v16
583 %vc = sub <vscale x 16 x i32> %va, %vb
584 ret <vscale x 16 x i32> %vc
587 define <vscale x 16 x i32> @vsub_vx_nxv16i32(<vscale x 16 x i32> %va, i32 signext %b) {
588 ; CHECK-LABEL: vsub_vx_nxv16i32:
590 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
591 ; CHECK-NEXT: vsub.vx v8, v8, a0
593 %head = insertelement <vscale x 16 x i32> poison, i32 %b, i32 0
594 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
595 %vc = sub <vscale x 16 x i32> %va, %splat
596 ret <vscale x 16 x i32> %vc
599 define <vscale x 16 x i32> @vsub_vx_nxv16i32_0(<vscale x 16 x i32> %va) {
600 ; CHECK-LABEL: vsub_vx_nxv16i32_0:
602 ; CHECK-NEXT: li a0, 1
603 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
604 ; CHECK-NEXT: vsub.vx v8, v8, a0
606 %vc = sub <vscale x 16 x i32> %va, splat (i32 1)
607 ret <vscale x 16 x i32> %vc
610 define <vscale x 1 x i64> @vsub_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
611 ; CHECK-LABEL: vsub_vv_nxv1i64:
613 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
614 ; CHECK-NEXT: vsub.vv v8, v8, v9
616 %vc = sub <vscale x 1 x i64> %va, %vb
617 ret <vscale x 1 x i64> %vc
620 define <vscale x 1 x i64> @vsub_vx_nxv1i64(<vscale x 1 x i64> %va, i64 %b) {
621 ; RV32-LABEL: vsub_vx_nxv1i64:
623 ; RV32-NEXT: addi sp, sp, -16
624 ; RV32-NEXT: .cfi_def_cfa_offset 16
625 ; RV32-NEXT: sw a1, 12(sp)
626 ; RV32-NEXT: sw a0, 8(sp)
627 ; RV32-NEXT: addi a0, sp, 8
628 ; RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma
629 ; RV32-NEXT: vlse64.v v9, (a0), zero
630 ; RV32-NEXT: vsub.vv v8, v8, v9
631 ; RV32-NEXT: addi sp, sp, 16
634 ; RV64-LABEL: vsub_vx_nxv1i64:
636 ; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma
637 ; RV64-NEXT: vsub.vx v8, v8, a0
639 %head = insertelement <vscale x 1 x i64> poison, i64 %b, i32 0
640 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
641 %vc = sub <vscale x 1 x i64> %va, %splat
642 ret <vscale x 1 x i64> %vc
645 define <vscale x 1 x i64> @vsub_vx_nxv1i64_0(<vscale x 1 x i64> %va) {
646 ; CHECK-LABEL: vsub_vx_nxv1i64_0:
648 ; CHECK-NEXT: li a0, 1
649 ; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma
650 ; CHECK-NEXT: vsub.vx v8, v8, a0
652 %vc = sub <vscale x 1 x i64> %va, splat (i64 1)
653 ret <vscale x 1 x i64> %vc
656 define <vscale x 2 x i64> @vsub_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
657 ; CHECK-LABEL: vsub_vv_nxv2i64:
659 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
660 ; CHECK-NEXT: vsub.vv v8, v8, v10
662 %vc = sub <vscale x 2 x i64> %va, %vb
663 ret <vscale x 2 x i64> %vc
666 define <vscale x 2 x i64> @vsub_vx_nxv2i64(<vscale x 2 x i64> %va, i64 %b) {
667 ; RV32-LABEL: vsub_vx_nxv2i64:
669 ; RV32-NEXT: addi sp, sp, -16
670 ; RV32-NEXT: .cfi_def_cfa_offset 16
671 ; RV32-NEXT: sw a1, 12(sp)
672 ; RV32-NEXT: sw a0, 8(sp)
673 ; RV32-NEXT: addi a0, sp, 8
674 ; RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma
675 ; RV32-NEXT: vlse64.v v10, (a0), zero
676 ; RV32-NEXT: vsub.vv v8, v8, v10
677 ; RV32-NEXT: addi sp, sp, 16
680 ; RV64-LABEL: vsub_vx_nxv2i64:
682 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
683 ; RV64-NEXT: vsub.vx v8, v8, a0
685 %head = insertelement <vscale x 2 x i64> poison, i64 %b, i32 0
686 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
687 %vc = sub <vscale x 2 x i64> %va, %splat
688 ret <vscale x 2 x i64> %vc
691 define <vscale x 2 x i64> @vsub_vx_nxv2i64_0(<vscale x 2 x i64> %va) {
692 ; CHECK-LABEL: vsub_vx_nxv2i64_0:
694 ; CHECK-NEXT: li a0, 1
695 ; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma
696 ; CHECK-NEXT: vsub.vx v8, v8, a0
698 %vc = sub <vscale x 2 x i64> %va, splat (i64 1)
699 ret <vscale x 2 x i64> %vc
702 define <vscale x 4 x i64> @vsub_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
703 ; CHECK-LABEL: vsub_vv_nxv4i64:
705 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
706 ; CHECK-NEXT: vsub.vv v8, v8, v12
708 %vc = sub <vscale x 4 x i64> %va, %vb
709 ret <vscale x 4 x i64> %vc
712 define <vscale x 4 x i64> @vsub_vx_nxv4i64(<vscale x 4 x i64> %va, i64 %b) {
713 ; RV32-LABEL: vsub_vx_nxv4i64:
715 ; RV32-NEXT: addi sp, sp, -16
716 ; RV32-NEXT: .cfi_def_cfa_offset 16
717 ; RV32-NEXT: sw a1, 12(sp)
718 ; RV32-NEXT: sw a0, 8(sp)
719 ; RV32-NEXT: addi a0, sp, 8
720 ; RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma
721 ; RV32-NEXT: vlse64.v v12, (a0), zero
722 ; RV32-NEXT: vsub.vv v8, v8, v12
723 ; RV32-NEXT: addi sp, sp, 16
726 ; RV64-LABEL: vsub_vx_nxv4i64:
728 ; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma
729 ; RV64-NEXT: vsub.vx v8, v8, a0
731 %head = insertelement <vscale x 4 x i64> poison, i64 %b, i32 0
732 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
733 %vc = sub <vscale x 4 x i64> %va, %splat
734 ret <vscale x 4 x i64> %vc
737 define <vscale x 4 x i64> @vsub_vx_nxv4i64_0(<vscale x 4 x i64> %va) {
738 ; CHECK-LABEL: vsub_vx_nxv4i64_0:
740 ; CHECK-NEXT: li a0, 1
741 ; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma
742 ; CHECK-NEXT: vsub.vx v8, v8, a0
744 %vc = sub <vscale x 4 x i64> %va, splat (i64 1)
745 ret <vscale x 4 x i64> %vc
748 define <vscale x 8 x i64> @vsub_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
749 ; CHECK-LABEL: vsub_vv_nxv8i64:
751 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
752 ; CHECK-NEXT: vsub.vv v8, v8, v16
754 %vc = sub <vscale x 8 x i64> %va, %vb
755 ret <vscale x 8 x i64> %vc
758 define <vscale x 8 x i64> @vsub_vx_nxv8i64(<vscale x 8 x i64> %va, i64 %b) {
759 ; RV32-LABEL: vsub_vx_nxv8i64:
761 ; RV32-NEXT: addi sp, sp, -16
762 ; RV32-NEXT: .cfi_def_cfa_offset 16
763 ; RV32-NEXT: sw a1, 12(sp)
764 ; RV32-NEXT: sw a0, 8(sp)
765 ; RV32-NEXT: addi a0, sp, 8
766 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
767 ; RV32-NEXT: vlse64.v v16, (a0), zero
768 ; RV32-NEXT: vsub.vv v8, v8, v16
769 ; RV32-NEXT: addi sp, sp, 16
772 ; RV64-LABEL: vsub_vx_nxv8i64:
774 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
775 ; RV64-NEXT: vsub.vx v8, v8, a0
777 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
778 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
779 %vc = sub <vscale x 8 x i64> %va, %splat
780 ret <vscale x 8 x i64> %vc
783 define <vscale x 8 x i64> @vsub_vx_nxv8i64_0(<vscale x 8 x i64> %va) {
784 ; CHECK-LABEL: vsub_vx_nxv8i64_0:
786 ; CHECK-NEXT: li a0, 1
787 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
788 ; CHECK-NEXT: vsub.vx v8, v8, a0
790 %vc = sub <vscale x 8 x i64> %va, splat (i64 1)
791 ret <vscale x 8 x i64> %vc
794 define <vscale x 8 x i64> @vsub_xx_nxv8i64(i64 %a, i64 %b) nounwind {
795 ; RV32-LABEL: vsub_xx_nxv8i64:
797 ; RV32-NEXT: addi sp, sp, -16
798 ; RV32-NEXT: sw a1, 12(sp)
799 ; RV32-NEXT: sw a0, 8(sp)
800 ; RV32-NEXT: addi a0, sp, 8
801 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
802 ; RV32-NEXT: vlse64.v v8, (a0), zero
803 ; RV32-NEXT: sw a3, 4(sp)
804 ; RV32-NEXT: sw a2, 0(sp)
805 ; RV32-NEXT: mv a0, sp
806 ; RV32-NEXT: vlse64.v v16, (a0), zero
807 ; RV32-NEXT: vsub.vv v8, v8, v16
808 ; RV32-NEXT: addi sp, sp, 16
811 ; RV64-LABEL: vsub_xx_nxv8i64:
813 ; RV64-NEXT: sub a0, a0, a1
814 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
815 ; RV64-NEXT: vmv.v.x v8, a0
817 %head1 = insertelement <vscale x 8 x i64> poison, i64 %a, i32 0
818 %splat1 = shufflevector <vscale x 8 x i64> %head1, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
819 %head2 = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
820 %splat2 = shufflevector <vscale x 8 x i64> %head2, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
821 %v = sub <vscale x 8 x i64> %splat1, %splat2
822 ret <vscale x 8 x i64> %v
825 define <vscale x 8 x i32> @vsub_vv_mask_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb, <vscale x 8 x i1> %mask) {
826 ; CHECK-LABEL: vsub_vv_mask_nxv8i32:
828 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu
829 ; CHECK-NEXT: vsub.vv v8, v8, v12, v0.t
832 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %vb, <vscale x 8 x i32> zeroinitializer
833 %vc = sub <vscale x 8 x i32> %va, %vs
834 ret <vscale x 8 x i32> %vc
837 define <vscale x 8 x i32> @vsub_vx_mask_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b, <vscale x 8 x i1> %mask) {
838 ; CHECK-LABEL: vsub_vx_mask_nxv8i32:
840 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu
841 ; CHECK-NEXT: vsub.vx v8, v8, a0, v0.t
843 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
844 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
845 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %splat, <vscale x 8 x i32> zeroinitializer
846 %vc = sub <vscale x 8 x i32> %va, %vs
847 ret <vscale x 8 x i32> %vc
850 define <vscale x 8 x i32> @vsub_vi_mask_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i1> %mask) {
851 ; CHECK-LABEL: vsub_vi_mask_nxv8i32:
853 ; CHECK-NEXT: li a0, 7
854 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu
855 ; CHECK-NEXT: vsub.vx v8, v8, a0, v0.t
857 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> splat (i32 7), <vscale x 8 x i32> zeroinitializer
858 %vc = sub <vscale x 8 x i32> %va, %vs
859 ret <vscale x 8 x i32> %vc