1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32,RV32-ZVFH
3 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64,RV64-ZVFH
4 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zvfhmin,+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32,RV32-ZVFHMIN
5 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zvfhmin,+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64,RV64-ZVFHMIN
7 define <4 x half> @shuffle_v4f16(<4 x half> %x, <4 x half> %y) {
8 ; CHECK-LABEL: shuffle_v4f16:
10 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
11 ; CHECK-NEXT: vmv.v.i v0, 11
12 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
14 %s = shufflevector <4 x half> %x, <4 x half> %y, <4 x i32> <i32 0, i32 1, i32 6, i32 3>
18 define <8 x float> @shuffle_v8f32(<8 x float> %x, <8 x float> %y) {
19 ; CHECK-LABEL: shuffle_v8f32:
21 ; CHECK-NEXT: li a0, -20
22 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
23 ; CHECK-NEXT: vmv.s.x v0, a0
24 ; CHECK-NEXT: vmerge.vvm v8, v10, v8, v0
26 %s = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 8, i32 9, i32 2, i32 3, i32 12, i32 5, i32 6, i32 7>
30 define <4 x double> @shuffle_fv_v4f64(<4 x double> %x) {
31 ; CHECK-LABEL: shuffle_fv_v4f64:
33 ; CHECK-NEXT: lui a0, %hi(.LCPI2_0)
34 ; CHECK-NEXT: fld fa5, %lo(.LCPI2_0)(a0)
35 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
36 ; CHECK-NEXT: vmv.v.i v0, 9
37 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
38 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa5, v0
40 %s = shufflevector <4 x double> <double 2.0, double 2.0, double 2.0, double 2.0>, <4 x double> %x, <4 x i32> <i32 0, i32 5, i32 6, i32 3>
44 define <4 x double> @shuffle_vf_v4f64(<4 x double> %x) {
45 ; CHECK-LABEL: shuffle_vf_v4f64:
47 ; CHECK-NEXT: lui a0, %hi(.LCPI3_0)
48 ; CHECK-NEXT: fld fa5, %lo(.LCPI3_0)(a0)
49 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
50 ; CHECK-NEXT: vmv.v.i v0, 6
51 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
52 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa5, v0
54 %s = shufflevector <4 x double> %x, <4 x double> <double 2.0, double 2.0, double 2.0, double 2.0>, <4 x i32> <i32 0, i32 5, i32 6, i32 3>
58 define <4 x double> @vrgather_permute_shuffle_vu_v4f64(<4 x double> %x) {
59 ; CHECK-LABEL: vrgather_permute_shuffle_vu_v4f64:
61 ; CHECK-NEXT: lui a0, 4096
62 ; CHECK-NEXT: addi a0, a0, 513
63 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
64 ; CHECK-NEXT: vmv.s.x v10, a0
65 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
66 ; CHECK-NEXT: vsext.vf2 v12, v10
67 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
68 ; CHECK-NEXT: vrgatherei16.vv v10, v8, v12
69 ; CHECK-NEXT: vmv.v.v v8, v10
71 %s = shufflevector <4 x double> %x, <4 x double> poison, <4 x i32> <i32 1, i32 2, i32 0, i32 1>
75 define <4 x double> @vrgather_permute_shuffle_uv_v4f64(<4 x double> %x) {
76 ; CHECK-LABEL: vrgather_permute_shuffle_uv_v4f64:
78 ; CHECK-NEXT: lui a0, 4096
79 ; CHECK-NEXT: addi a0, a0, 513
80 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
81 ; CHECK-NEXT: vmv.s.x v10, a0
82 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
83 ; CHECK-NEXT: vsext.vf2 v12, v10
84 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
85 ; CHECK-NEXT: vrgatherei16.vv v10, v8, v12
86 ; CHECK-NEXT: vmv.v.v v8, v10
88 %s = shufflevector <4 x double> poison, <4 x double> %x, <4 x i32> <i32 5, i32 6, i32 4, i32 5>
92 define <4 x double> @vrgather_shuffle_vv_v4f64(<4 x double> %x, <4 x double> %y) {
93 ; CHECK-LABEL: vrgather_shuffle_vv_v4f64:
95 ; CHECK-NEXT: lui a0, %hi(.LCPI6_0)
96 ; CHECK-NEXT: addi a0, a0, %lo(.LCPI6_0)
97 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
98 ; CHECK-NEXT: vle16.v v14, (a0)
99 ; CHECK-NEXT: vmv.v.i v0, 8
100 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
101 ; CHECK-NEXT: vrgatherei16.vv v12, v8, v14
102 ; CHECK-NEXT: vrgather.vi v12, v10, 1, v0.t
103 ; CHECK-NEXT: vmv.v.v v8, v12
105 %s = shufflevector <4 x double> %x, <4 x double> %y, <4 x i32> <i32 1, i32 2, i32 0, i32 5>
109 define <4 x double> @vrgather_shuffle_xv_v4f64(<4 x double> %x) {
110 ; CHECK-LABEL: vrgather_shuffle_xv_v4f64:
112 ; CHECK-NEXT: lui a0, %hi(.LCPI7_0)
113 ; CHECK-NEXT: fld fa5, %lo(.LCPI7_0)(a0)
114 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
115 ; CHECK-NEXT: vid.v v10
116 ; CHECK-NEXT: vrsub.vi v12, v10, 4
117 ; CHECK-NEXT: vmv.v.i v0, 12
118 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
119 ; CHECK-NEXT: vfmv.v.f v10, fa5
120 ; CHECK-NEXT: vrgatherei16.vv v10, v8, v12, v0.t
121 ; CHECK-NEXT: vmv.v.v v8, v10
123 %s = shufflevector <4 x double> <double 2.0, double 2.0, double 2.0, double 2.0>, <4 x double> %x, <4 x i32> <i32 0, i32 3, i32 6, i32 5>
127 define <4 x double> @vrgather_shuffle_vx_v4f64(<4 x double> %x) {
128 ; CHECK-LABEL: vrgather_shuffle_vx_v4f64:
130 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
131 ; CHECK-NEXT: vid.v v10
132 ; CHECK-NEXT: lui a0, %hi(.LCPI8_0)
133 ; CHECK-NEXT: fld fa5, %lo(.LCPI8_0)(a0)
134 ; CHECK-NEXT: li a0, 3
135 ; CHECK-NEXT: vmul.vx v12, v10, a0
136 ; CHECK-NEXT: vmv.v.i v0, 3
137 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
138 ; CHECK-NEXT: vfmv.v.f v10, fa5
139 ; CHECK-NEXT: vrgatherei16.vv v10, v8, v12, v0.t
140 ; CHECK-NEXT: vmv.v.v v8, v10
142 %s = shufflevector <4 x double> %x, <4 x double> <double 2.0, double 2.0, double 2.0, double 2.0>, <4 x i32> <i32 0, i32 3, i32 6, i32 5>
146 define <4 x half> @shuffle_v8f16_to_vslidedown_1(<8 x half> %x) {
147 ; CHECK-LABEL: shuffle_v8f16_to_vslidedown_1:
148 ; CHECK: # %bb.0: # %entry
149 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
150 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
153 %s = shufflevector <8 x half> %x, <8 x half> poison, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
157 define <4 x half> @shuffle_v8f16_to_vslidedown_3(<8 x half> %x) {
158 ; CHECK-LABEL: shuffle_v8f16_to_vslidedown_3:
159 ; CHECK: # %bb.0: # %entry
160 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
161 ; CHECK-NEXT: vslidedown.vi v8, v8, 3
164 %s = shufflevector <8 x half> %x, <8 x half> poison, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
168 define <2 x float> @shuffle_v4f32_to_vslidedown(<4 x float> %x) {
169 ; CHECK-LABEL: shuffle_v4f32_to_vslidedown:
170 ; CHECK: # %bb.0: # %entry
171 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
172 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
175 %s = shufflevector <4 x float> %x, <4 x float> poison, <2 x i32> <i32 1, i32 2>
179 define <4 x half> @slidedown_v4f16(<4 x half> %x) {
180 ; CHECK-LABEL: slidedown_v4f16:
182 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
183 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
185 %s = shufflevector <4 x half> %x, <4 x half> poison, <4 x i32> <i32 1, i32 2, i32 3, i32 undef>
189 define <8 x float> @slidedown_v8f32(<8 x float> %x) {
190 ; CHECK-LABEL: slidedown_v8f32:
192 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
193 ; CHECK-NEXT: vslidedown.vi v8, v8, 3
195 %s = shufflevector <8 x float> %x, <8 x float> poison, <8 x i32> <i32 3, i32 undef, i32 5, i32 6, i32 undef, i32 undef, i32 undef, i32 undef>
199 define <4 x half> @slideup_v4f16(<4 x half> %x) {
200 ; CHECK-LABEL: slideup_v4f16:
202 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
203 ; CHECK-NEXT: vslideup.vi v9, v8, 1
204 ; CHECK-NEXT: vmv1r.v v8, v9
206 %s = shufflevector <4 x half> %x, <4 x half> poison, <4 x i32> <i32 undef, i32 0, i32 1, i32 2>
210 define <8 x float> @slideup_v8f32(<8 x float> %x) {
211 ; CHECK-LABEL: slideup_v8f32:
213 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
214 ; CHECK-NEXT: vslideup.vi v10, v8, 3
215 ; CHECK-NEXT: vmv.v.v v8, v10
217 %s = shufflevector <8 x float> %x, <8 x float> poison, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 1, i32 2, i32 3, i32 4>
221 define <8 x float> @splice_unary(<8 x float> %x) {
222 ; CHECK-LABEL: splice_unary:
224 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
225 ; CHECK-NEXT: vslidedown.vi v10, v8, 1
226 ; CHECK-NEXT: vslideup.vi v10, v8, 7
227 ; CHECK-NEXT: vmv.v.v v8, v10
229 %s = shufflevector <8 x float> %x, <8 x float> poison, <8 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0>
233 define <8 x double> @splice_unary2(<8 x double> %x) {
234 ; CHECK-LABEL: splice_unary2:
236 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, ma
237 ; CHECK-NEXT: vslidedown.vi v12, v8, 6
238 ; CHECK-NEXT: vslideup.vi v12, v8, 2
239 ; CHECK-NEXT: vmv.v.v v8, v12
241 %s = shufflevector <8 x double> %x, <8 x double> poison, <8 x i32> <i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>
245 define <8 x float> @splice_binary(<8 x float> %x, <8 x float> %y) {
246 ; CHECK-LABEL: splice_binary:
248 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
249 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
250 ; CHECK-NEXT: vslideup.vi v8, v10, 6
252 %s = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 undef, i32 9>
256 define <8 x double> @splice_binary2(<8 x double> %x, <8 x double> %y) {
257 ; CHECK-LABEL: splice_binary2:
259 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, ma
260 ; CHECK-NEXT: vslidedown.vi v12, v12, 5
261 ; CHECK-NEXT: vslideup.vi v12, v8, 3
262 ; CHECK-NEXT: vmv.v.v v8, v12
264 %s = shufflevector <8 x double> %x, <8 x double> %y, <8 x i32> <i32 13, i32 14, i32 15, i32 0, i32 1, i32 2, i32 3, i32 4>
268 define <4 x half> @vrgather_permute_shuffle_vu_v4f16(<4 x half> %x) {
269 ; CHECK-LABEL: vrgather_permute_shuffle_vu_v4f16:
271 ; CHECK-NEXT: lui a0, 4096
272 ; CHECK-NEXT: addi a0, a0, 513
273 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
274 ; CHECK-NEXT: vmv.s.x v9, a0
275 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
276 ; CHECK-NEXT: vsext.vf2 v10, v9
277 ; CHECK-NEXT: vrgather.vv v9, v8, v10
278 ; CHECK-NEXT: vmv1r.v v8, v9
280 %s = shufflevector <4 x half> %x, <4 x half> poison, <4 x i32> <i32 1, i32 2, i32 0, i32 1>
284 define <4 x half> @vrgather_shuffle_vv_v4f16(<4 x half> %x, <4 x half> %y) {
285 ; CHECK-LABEL: vrgather_shuffle_vv_v4f16:
287 ; CHECK-NEXT: lui a0, %hi(.LCPI21_0)
288 ; CHECK-NEXT: addi a0, a0, %lo(.LCPI21_0)
289 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, mu
290 ; CHECK-NEXT: vle16.v v11, (a0)
291 ; CHECK-NEXT: vmv.v.i v0, 8
292 ; CHECK-NEXT: vrgather.vv v10, v8, v11
293 ; CHECK-NEXT: vrgather.vi v10, v9, 1, v0.t
294 ; CHECK-NEXT: vmv1r.v v8, v10
296 %s = shufflevector <4 x half> %x, <4 x half> %y, <4 x i32> <i32 1, i32 2, i32 0, i32 5>
300 define <4 x half> @vrgather_shuffle_vx_v4f16_load(ptr %p) {
301 ; RV32-ZVFH-LABEL: vrgather_shuffle_vx_v4f16_load:
302 ; RV32-ZVFH: # %bb.0:
303 ; RV32-ZVFH-NEXT: flh fa5, 2(a0)
304 ; RV32-ZVFH-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
305 ; RV32-ZVFH-NEXT: vfmv.v.f v8, fa5
306 ; RV32-ZVFH-NEXT: ret
308 ; RV64-ZVFH-LABEL: vrgather_shuffle_vx_v4f16_load:
309 ; RV64-ZVFH: # %bb.0:
310 ; RV64-ZVFH-NEXT: flh fa5, 2(a0)
311 ; RV64-ZVFH-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
312 ; RV64-ZVFH-NEXT: vfmv.v.f v8, fa5
313 ; RV64-ZVFH-NEXT: ret
315 ; RV32-ZVFHMIN-LABEL: vrgather_shuffle_vx_v4f16_load:
316 ; RV32-ZVFHMIN: # %bb.0:
317 ; RV32-ZVFHMIN-NEXT: lh a0, 2(a0)
318 ; RV32-ZVFHMIN-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
319 ; RV32-ZVFHMIN-NEXT: vmv.v.x v8, a0
320 ; RV32-ZVFHMIN-NEXT: ret
322 ; RV64-ZVFHMIN-LABEL: vrgather_shuffle_vx_v4f16_load:
323 ; RV64-ZVFHMIN: # %bb.0:
324 ; RV64-ZVFHMIN-NEXT: lh a0, 2(a0)
325 ; RV64-ZVFHMIN-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
326 ; RV64-ZVFHMIN-NEXT: vmv.v.x v8, a0
327 ; RV64-ZVFHMIN-NEXT: ret
328 %v = load <4 x half>, ptr %p
329 %s = shufflevector <4 x half> %v, <4 x half> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
333 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: