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
3 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
5 define <4 x half> @shuffle_v4f16(<4 x half> %x, <4 x half> %y) {
6 ; CHECK-LABEL: shuffle_v4f16:
8 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
9 ; CHECK-NEXT: vmv.v.i v0, 11
10 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
11 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
13 %s = shufflevector <4 x half> %x, <4 x half> %y, <4 x i32> <i32 0, i32 1, i32 6, i32 3>
17 define <8 x float> @shuffle_v8f32(<8 x float> %x, <8 x float> %y) {
18 ; CHECK-LABEL: shuffle_v8f32:
20 ; CHECK-NEXT: li a0, 236
21 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
22 ; CHECK-NEXT: vmv.s.x v0, a0
23 ; CHECK-NEXT: vmerge.vvm v8, v10, v8, v0
25 %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>
29 define <4 x double> @shuffle_fv_v4f64(<4 x double> %x) {
30 ; CHECK-LABEL: shuffle_fv_v4f64:
32 ; CHECK-NEXT: lui a0, %hi(.LCPI2_0)
33 ; CHECK-NEXT: fld fa5, %lo(.LCPI2_0)(a0)
34 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
35 ; CHECK-NEXT: vmv.v.i v0, 9
36 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
37 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa5, v0
39 %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>
43 define <4 x double> @shuffle_vf_v4f64(<4 x double> %x) {
44 ; CHECK-LABEL: shuffle_vf_v4f64:
46 ; CHECK-NEXT: lui a0, %hi(.LCPI3_0)
47 ; CHECK-NEXT: fld fa5, %lo(.LCPI3_0)(a0)
48 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
49 ; CHECK-NEXT: vmv.v.i v0, 6
50 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
51 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa5, v0
53 %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>
57 define <4 x double> @vrgather_permute_shuffle_vu_v4f64(<4 x double> %x) {
58 ; CHECK-LABEL: vrgather_permute_shuffle_vu_v4f64:
60 ; CHECK-NEXT: lui a0, 4096
61 ; CHECK-NEXT: addi a0, a0, 513
62 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
63 ; CHECK-NEXT: vmv.s.x v10, a0
64 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
65 ; CHECK-NEXT: vsext.vf2 v12, v10
66 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
67 ; CHECK-NEXT: vrgatherei16.vv v10, v8, v12
68 ; CHECK-NEXT: vmv.v.v v8, v10
70 %s = shufflevector <4 x double> %x, <4 x double> poison, <4 x i32> <i32 1, i32 2, i32 0, i32 1>
74 define <4 x double> @vrgather_permute_shuffle_uv_v4f64(<4 x double> %x) {
75 ; CHECK-LABEL: vrgather_permute_shuffle_uv_v4f64:
77 ; CHECK-NEXT: lui a0, 4096
78 ; CHECK-NEXT: addi a0, a0, 513
79 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
80 ; CHECK-NEXT: vmv.s.x v10, a0
81 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
82 ; CHECK-NEXT: vsext.vf2 v12, v10
83 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
84 ; CHECK-NEXT: vrgatherei16.vv v10, v8, v12
85 ; CHECK-NEXT: vmv.v.v v8, v10
87 %s = shufflevector <4 x double> poison, <4 x double> %x, <4 x i32> <i32 5, i32 6, i32 4, i32 5>
91 define <4 x double> @vrgather_shuffle_vv_v4f64(<4 x double> %x, <4 x double> %y) {
92 ; CHECK-LABEL: vrgather_shuffle_vv_v4f64:
94 ; CHECK-NEXT: lui a0, %hi(.LCPI6_0)
95 ; CHECK-NEXT: addi a0, a0, %lo(.LCPI6_0)
96 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
97 ; CHECK-NEXT: vle16.v v14, (a0)
98 ; CHECK-NEXT: vrgatherei16.vv v12, v8, v14
99 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
100 ; CHECK-NEXT: vmv.v.i v0, 8
101 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, mu
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: vsetivli zero, 4, e16, mf2, ta, ma
113 ; CHECK-NEXT: vid.v v12
114 ; CHECK-NEXT: lui a0, %hi(.LCPI7_0)
115 ; CHECK-NEXT: addi a0, a0, %lo(.LCPI7_0)
116 ; CHECK-NEXT: vlse64.v v10, (a0), zero
117 ; CHECK-NEXT: vrsub.vi v12, v12, 4
118 ; CHECK-NEXT: vmv.v.i v0, 12
119 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
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 ; RV32-LABEL: vrgather_shuffle_vx_v4f64:
130 ; RV32-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
131 ; RV32-NEXT: vid.v v12
132 ; RV32-NEXT: li a0, 3
133 ; RV32-NEXT: lui a1, %hi(.LCPI8_0)
134 ; RV32-NEXT: addi a1, a1, %lo(.LCPI8_0)
135 ; RV32-NEXT: vlse64.v v10, (a1), zero
136 ; RV32-NEXT: vmul.vx v12, v12, a0
137 ; RV32-NEXT: vmv.v.i v0, 3
138 ; RV32-NEXT: vsetvli zero, zero, e64, m2, ta, mu
139 ; RV32-NEXT: vrgatherei16.vv v10, v8, v12, v0.t
140 ; RV32-NEXT: vmv.v.v v8, v10
143 ; RV64-LABEL: vrgather_shuffle_vx_v4f64:
145 ; RV64-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
146 ; RV64-NEXT: vid.v v12
147 ; RV64-NEXT: lui a0, %hi(.LCPI8_0)
148 ; RV64-NEXT: addi a0, a0, %lo(.LCPI8_0)
149 ; RV64-NEXT: vlse64.v v10, (a0), zero
150 ; RV64-NEXT: li a0, 3
151 ; RV64-NEXT: vmul.vx v12, v12, a0
152 ; RV64-NEXT: vmv.v.i v0, 3
153 ; RV64-NEXT: vsetvli zero, zero, e64, m2, ta, mu
154 ; RV64-NEXT: vrgatherei16.vv v10, v8, v12, v0.t
155 ; RV64-NEXT: vmv.v.v v8, v10
157 %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>
161 define <4 x half> @shuffle_v8f16_to_vslidedown_1(<8 x half> %x) {
162 ; CHECK-LABEL: shuffle_v8f16_to_vslidedown_1:
163 ; CHECK: # %bb.0: # %entry
164 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
165 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
168 %s = shufflevector <8 x half> %x, <8 x half> poison, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
172 define <4 x half> @shuffle_v8f16_to_vslidedown_3(<8 x half> %x) {
173 ; CHECK-LABEL: shuffle_v8f16_to_vslidedown_3:
174 ; CHECK: # %bb.0: # %entry
175 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
176 ; CHECK-NEXT: vslidedown.vi v8, v8, 3
179 %s = shufflevector <8 x half> %x, <8 x half> poison, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
183 define <2 x float> @shuffle_v4f32_to_vslidedown(<4 x float> %x) {
184 ; CHECK-LABEL: shuffle_v4f32_to_vslidedown:
185 ; CHECK: # %bb.0: # %entry
186 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
187 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
190 %s = shufflevector <4 x float> %x, <4 x float> poison, <2 x i32> <i32 1, i32 2>
194 define <4 x half> @slidedown_v4f16(<4 x half> %x) {
195 ; CHECK-LABEL: slidedown_v4f16:
197 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
198 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
200 %s = shufflevector <4 x half> %x, <4 x half> poison, <4 x i32> <i32 1, i32 2, i32 3, i32 undef>
204 define <8 x float> @slidedown_v8f32(<8 x float> %x) {
205 ; CHECK-LABEL: slidedown_v8f32:
207 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
208 ; CHECK-NEXT: vslidedown.vi v8, v8, 3
210 %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>
214 define <4 x half> @slideup_v4f16(<4 x half> %x) {
215 ; CHECK-LABEL: slideup_v4f16:
217 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
218 ; CHECK-NEXT: vslideup.vi v9, v8, 1
219 ; CHECK-NEXT: vmv1r.v v8, v9
221 %s = shufflevector <4 x half> %x, <4 x half> poison, <4 x i32> <i32 undef, i32 0, i32 1, i32 2>
225 define <8 x float> @slideup_v8f32(<8 x float> %x) {
226 ; CHECK-LABEL: slideup_v8f32:
228 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
229 ; CHECK-NEXT: vslideup.vi v10, v8, 3
230 ; CHECK-NEXT: vmv.v.v v8, v10
232 %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>
236 define <8 x float> @splice_unary(<8 x float> %x) {
237 ; CHECK-LABEL: splice_unary:
239 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
240 ; CHECK-NEXT: vslidedown.vi v10, v8, 1
241 ; CHECK-NEXT: vslideup.vi v10, v8, 7
242 ; CHECK-NEXT: vmv.v.v v8, v10
244 %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>
248 define <8 x double> @splice_unary2(<8 x double> %x) {
249 ; CHECK-LABEL: splice_unary2:
251 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, ma
252 ; CHECK-NEXT: vslidedown.vi v12, v8, 6
253 ; CHECK-NEXT: vslideup.vi v12, v8, 2
254 ; CHECK-NEXT: vmv.v.v v8, v12
256 %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>
260 define <8 x float> @splice_binary(<8 x float> %x, <8 x float> %y) {
261 ; CHECK-LABEL: splice_binary:
263 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
264 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
265 ; CHECK-NEXT: vslideup.vi v8, v10, 6
267 %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>
271 define <8 x double> @splice_binary2(<8 x double> %x, <8 x double> %y) {
272 ; CHECK-LABEL: splice_binary2:
274 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, ma
275 ; CHECK-NEXT: vslidedown.vi v12, v12, 5
276 ; CHECK-NEXT: vslideup.vi v12, v8, 3
277 ; CHECK-NEXT: vmv.v.v v8, v12
279 %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>