1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=riscv32 -mattr=+m,+v,+f,+d,+zfh,+zvfh -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+m,+v,+f,+d,+zfh,+zvfh -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7 define <2 x i8> @vslide1down_2xi8(<2 x i8> %v, i8 %b) {
8 ; CHECK-LABEL: vslide1down_2xi8:
10 ; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, ma
11 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
13 %vb = insertelement <2 x i8> poison, i8 %b, i64 0
14 %v1 = shufflevector <2 x i8> %v, <2 x i8> %vb, <2 x i32> <i32 1, i32 2>
18 define <4 x i8> @vslide1down_4xi8(<4 x i8> %v, i8 %b) {
19 ; CHECK-LABEL: vslide1down_4xi8:
21 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
22 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
24 %vb = insertelement <4 x i8> poison, i8 %b, i64 0
25 %v1 = shufflevector <4 x i8> %v, <4 x i8> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
29 define <4 x i8> @vslide1down_4xi8_swapped(<4 x i8> %v, i8 %b) {
30 ; CHECK-LABEL: vslide1down_4xi8_swapped:
32 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
33 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
35 %vb = insertelement <4 x i8> poison, i8 %b, i64 0
36 %v1 = shufflevector <4 x i8> %vb, <4 x i8> %v, <4 x i32> <i32 5, i32 6, i32 7, i32 0>
40 define <2 x i16> @vslide1down_2xi16(<2 x i16> %v, i16 %b) {
41 ; CHECK-LABEL: vslide1down_2xi16:
43 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
44 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
46 %vb = insertelement <2 x i16> poison, i16 %b, i64 0
47 %v1 = shufflevector <2 x i16> %v, <2 x i16> %vb, <2 x i32> <i32 1, i32 2>
51 define <4 x i16> @vslide1down_4xi16(<4 x i16> %v, i16 %b) {
52 ; CHECK-LABEL: vslide1down_4xi16:
54 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
55 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
57 %vb = insertelement <4 x i16> poison, i16 %b, i64 0
58 %v1 = shufflevector <4 x i16> %v, <4 x i16> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
62 define <2 x i32> @vslide1down_2xi32(<2 x i32> %v, i32 %b) {
63 ; CHECK-LABEL: vslide1down_2xi32:
65 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
66 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
68 %vb = insertelement <2 x i32> poison, i32 %b, i64 0
69 %v1 = shufflevector <2 x i32> %v, <2 x i32> %vb, <2 x i32> <i32 1, i32 2>
73 define <4 x i32> @vslide1down_4xi32(<4 x i32> %v, i32 %b) {
74 ; CHECK-LABEL: vslide1down_4xi32:
76 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
77 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
79 %vb = insertelement <4 x i32> poison, i32 %b, i64 0
80 %v1 = shufflevector <4 x i32> %v, <4 x i32> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
84 define <2 x i64> @vslide1down_2xi64(<2 x i64> %v, i64 %b) {
85 ; RV32-LABEL: vslide1down_2xi64:
87 ; RV32-NEXT: addi sp, sp, -16
88 ; RV32-NEXT: .cfi_def_cfa_offset 16
89 ; RV32-NEXT: sw a1, 12(sp)
90 ; RV32-NEXT: sw a0, 8(sp)
91 ; RV32-NEXT: addi a0, sp, 8
92 ; RV32-NEXT: vsetivli zero, 2, e64, m1, ta, ma
93 ; RV32-NEXT: vlse64.v v9, (a0), zero
94 ; RV32-NEXT: vslidedown.vi v8, v8, 1
95 ; RV32-NEXT: vslideup.vi v8, v9, 1
96 ; RV32-NEXT: addi sp, sp, 16
99 ; RV64-LABEL: vslide1down_2xi64:
101 ; RV64-NEXT: vsetivli zero, 2, e64, m1, ta, ma
102 ; RV64-NEXT: vslide1down.vx v8, v8, a0
104 %vb = insertelement <2 x i64> poison, i64 %b, i64 0
105 %v1 = shufflevector <2 x i64> %v, <2 x i64> %vb, <2 x i32> <i32 1, i32 2>
109 define <4 x i64> @vslide1down_4xi64(<4 x i64> %v, i64 %b) {
110 ; RV32-LABEL: vslide1down_4xi64:
112 ; RV32-NEXT: addi sp, sp, -16
113 ; RV32-NEXT: .cfi_def_cfa_offset 16
114 ; RV32-NEXT: sw a1, 12(sp)
115 ; RV32-NEXT: sw a0, 8(sp)
116 ; RV32-NEXT: addi a0, sp, 8
117 ; RV32-NEXT: vsetivli zero, 4, e64, m2, ta, ma
118 ; RV32-NEXT: vlse64.v v10, (a0), zero
119 ; RV32-NEXT: vslidedown.vi v8, v8, 1
120 ; RV32-NEXT: vslideup.vi v8, v10, 3
121 ; RV32-NEXT: addi sp, sp, 16
124 ; RV64-LABEL: vslide1down_4xi64:
126 ; RV64-NEXT: vsetivli zero, 4, e64, m2, ta, ma
127 ; RV64-NEXT: vslide1down.vx v8, v8, a0
129 %vb = insertelement <4 x i64> poison, i64 %b, i64 0
130 %v1 = shufflevector <4 x i64> %v, <4 x i64> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
134 define <2 x half> @vslide1down_2xf16(<2 x half> %v, half %b) {
135 ; CHECK-LABEL: vslide1down_2xf16:
137 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
138 ; CHECK-NEXT: vfslide1down.vf v8, v8, fa0
140 %vb = insertelement <2 x half> poison, half %b, i64 0
141 %v1 = shufflevector <2 x half> %v, <2 x half> %vb, <2 x i32> <i32 1, i32 2>
145 define <4 x half> @vslide1down_4xf16(<4 x half> %v, half %b) {
146 ; CHECK-LABEL: vslide1down_4xf16:
148 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
149 ; CHECK-NEXT: vfslide1down.vf v8, v8, fa0
151 %vb = insertelement <4 x half> poison, half %b, i64 0
152 %v1 = shufflevector <4 x half> %v, <4 x half> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
156 define <2 x float> @vslide1down_2xf32(<2 x float> %v, float %b) {
157 ; CHECK-LABEL: vslide1down_2xf32:
159 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
160 ; CHECK-NEXT: vfslide1down.vf v8, v8, fa0
162 %vb = insertelement <2 x float> poison, float %b, i64 0
163 %v1 = shufflevector <2 x float> %v, <2 x float> %vb, <2 x i32> <i32 1, i32 2>
167 define <4 x float> @vslide1down_4xf32(<4 x float> %v, float %b) {
168 ; CHECK-LABEL: vslide1down_4xf32:
170 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
171 ; CHECK-NEXT: vfslide1down.vf v8, v8, fa0
173 %vb = insertelement <4 x float> poison, float %b, i64 0
174 %v1 = shufflevector <4 x float> %v, <4 x float> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
178 define <2 x double> @vslide1down_2xf64(<2 x double> %v, double %b) {
179 ; CHECK-LABEL: vslide1down_2xf64:
181 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
182 ; CHECK-NEXT: vfslide1down.vf v8, v8, fa0
184 %vb = insertelement <2 x double> poison, double %b, i64 0
185 %v1 = shufflevector <2 x double> %v, <2 x double> %vb, <2 x i32> <i32 1, i32 2>
189 define <4 x double> @vslide1down_4xf64(<4 x double> %v, double %b) {
190 ; CHECK-LABEL: vslide1down_4xf64:
192 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
193 ; CHECK-NEXT: vfslide1down.vf v8, v8, fa0
195 %vb = insertelement <4 x double> poison, double %b, i64 0
196 %v1 = shufflevector <4 x double> %v, <4 x double> %vb, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
200 define <4 x i8> @vslide1down_4xi8_with_splat(<4 x i8> %v, i8 %b) {
201 ; CHECK-LABEL: vslide1down_4xi8_with_splat:
203 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
204 ; CHECK-NEXT: vslide1down.vx v8, v8, a0
206 %vb = insertelement <4 x i8> poison, i8 %b, i64 0
207 %v1 = shufflevector <4 x i8> %vb, <4 x i8> poison, <4 x i32> zeroinitializer
208 %v2 = shufflevector <4 x i8> %v1, <4 x i8> %v, <4 x i32> <i32 5, i32 6, i32 7, i32 1>
212 define <2 x double> @vslide1down_v2f64_inverted(<2 x double> %v, double %b) {
213 ; CHECK-LABEL: vslide1down_v2f64_inverted:
215 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
216 ; CHECK-NEXT: vrgather.vi v9, v8, 0
217 ; CHECK-NEXT: vfmv.s.f v8, fa0
218 ; CHECK-NEXT: vslideup.vi v9, v8, 1
219 ; CHECK-NEXT: vmv.v.v v8, v9
221 %v1 = shufflevector <2 x double> %v, <2 x double> poison, <2 x i32> <i32 0, i32 0>
222 %v2 = insertelement <2 x double> %v1, double %b, i64 1
226 define <4 x i8> @vslide1down_4xi8_inverted(<4 x i8> %v, i8 %b) {
227 ; CHECK-LABEL: vslide1down_4xi8_inverted:
229 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
230 ; CHECK-NEXT: vslideup.vi v9, v8, 1
231 ; CHECK-NEXT: vmv.s.x v8, a0
232 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, tu, ma
233 ; CHECK-NEXT: vslideup.vi v9, v8, 1
234 ; CHECK-NEXT: vmv1r.v v8, v9
236 %v1 = shufflevector <4 x i8> %v, <4 x i8> poison, <4 x i32> <i32 undef, i32 0, i32 1, i32 2>
237 %v2 = insertelement <4 x i8> %v1, i8 %b, i64 1