1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v,+m,+zvl128b -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,V128,RV32-V128
3 ; RUN: llc -mtriple=riscv64 -mattr=+v,+m,+zvl128b -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,V128,RV64-V128
4 ; RUN: llc -mtriple=riscv32 -mattr=+v,+m,+zvl512b -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,V512,RV32-V512
5 ; RUN: llc -mtriple=riscv64 -mattr=+v,+m,+zvl512b -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,V512,RV64-V512
7 ; Test optimizing interleaves to widening arithmetic.
9 define <4 x i8> @interleave_v2i8(<2 x i8> %x, <2 x i8> %y) {
10 ; CHECK-LABEL: interleave_v2i8:
12 ; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, ma
13 ; CHECK-NEXT: vwaddu.vv v10, v8, v9
14 ; CHECK-NEXT: li a0, -1
15 ; CHECK-NEXT: vwmaccu.vx v10, a0, v9
16 ; CHECK-NEXT: vmv1r.v v8, v10
18 %a = shufflevector <2 x i8> %x, <2 x i8> %y, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
22 define <4 x i16> @interleave_v2i16(<2 x i16> %x, <2 x i16> %y) {
23 ; CHECK-LABEL: interleave_v2i16:
25 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
26 ; CHECK-NEXT: vwaddu.vv v10, v8, v9
27 ; CHECK-NEXT: li a0, -1
28 ; CHECK-NEXT: vwmaccu.vx v10, a0, v9
29 ; CHECK-NEXT: vmv1r.v v8, v10
31 %a = shufflevector <2 x i16> %x, <2 x i16> %y, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
35 ; Vector order switched for coverage.
36 define <4 x i32> @interleave_v2i32(<2 x i32> %x, <2 x i32> %y) {
37 ; CHECK-LABEL: interleave_v2i32:
39 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
40 ; CHECK-NEXT: vwaddu.vv v10, v9, v8
41 ; CHECK-NEXT: li a0, -1
42 ; CHECK-NEXT: vwmaccu.vx v10, a0, v8
43 ; CHECK-NEXT: vmv1r.v v8, v10
45 %a = shufflevector <2 x i32> %x, <2 x i32> %y, <4 x i32> <i32 2, i32 0, i32 3, i32 1>
49 ; One vXi64 test case to very that we don't optimize it.
50 ; FIXME: Is there better codegen we can do here?
51 define <4 x i64> @interleave_v2i64(<2 x i64> %x, <2 x i64> %y) {
52 ; V128-LABEL: interleave_v2i64:
54 ; V128-NEXT: vmv1r.v v12, v9
55 ; V128-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
57 ; V128-NEXT: vsrl.vi v14, v9, 1
58 ; V128-NEXT: vsetvli zero, zero, e64, m2, ta, ma
59 ; V128-NEXT: vrgatherei16.vv v10, v8, v14
60 ; V128-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
61 ; V128-NEXT: vmv.v.i v0, 10
62 ; V128-NEXT: vsetivli zero, 4, e64, m2, ta, mu
63 ; V128-NEXT: vrgatherei16.vv v10, v12, v14, v0.t
64 ; V128-NEXT: vmv.v.v v8, v10
67 ; RV32-V512-LABEL: interleave_v2i64:
69 ; RV32-V512-NEXT: vsetivli zero, 4, e16, mf4, ta, ma
70 ; RV32-V512-NEXT: vid.v v10
71 ; RV32-V512-NEXT: vsrl.vi v11, v10, 1
72 ; RV32-V512-NEXT: vmv.v.i v0, 10
73 ; RV32-V512-NEXT: vsetvli zero, zero, e64, m1, ta, mu
74 ; RV32-V512-NEXT: vrgatherei16.vv v10, v8, v11
75 ; RV32-V512-NEXT: vrgatherei16.vv v10, v9, v11, v0.t
76 ; RV32-V512-NEXT: vmv.v.v v8, v10
79 ; RV64-V512-LABEL: interleave_v2i64:
81 ; RV64-V512-NEXT: vsetivli zero, 4, e64, m1, ta, mu
82 ; RV64-V512-NEXT: vid.v v10
83 ; RV64-V512-NEXT: vsrl.vi v11, v10, 1
84 ; RV64-V512-NEXT: vmv.v.i v0, 10
85 ; RV64-V512-NEXT: vrgather.vv v10, v8, v11
86 ; RV64-V512-NEXT: vrgather.vv v10, v9, v11, v0.t
87 ; RV64-V512-NEXT: vmv.v.v v8, v10
89 %a = shufflevector <2 x i64> %x, <2 x i64> %y, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
93 ; Vector order switched for coverage.
94 define <8 x i8> @interleave_v4i8(<4 x i8> %x, <4 x i8> %y) {
95 ; V128-LABEL: interleave_v4i8:
97 ; V128-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
98 ; V128-NEXT: vwaddu.vv v10, v9, v8
99 ; V128-NEXT: li a0, -1
100 ; V128-NEXT: vwmaccu.vx v10, a0, v8
101 ; V128-NEXT: vmv1r.v v8, v10
104 ; V512-LABEL: interleave_v4i8:
106 ; V512-NEXT: vsetivli zero, 4, e8, mf8, ta, ma
107 ; V512-NEXT: vwaddu.vv v10, v9, v8
108 ; V512-NEXT: li a0, -1
109 ; V512-NEXT: vwmaccu.vx v10, a0, v8
110 ; V512-NEXT: vmv1r.v v8, v10
112 %a = shufflevector <4 x i8> %x, <4 x i8> %y, <8 x i32> <i32 4, i32 0, i32 5, i32 1, i32 6, i32 2, i32 7, i32 3>
116 ; Undef elements for coverage
117 define <8 x i16> @interleave_v4i16(<4 x i16> %x, <4 x i16> %y) {
118 ; V128-LABEL: interleave_v4i16:
120 ; V128-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
121 ; V128-NEXT: vwaddu.vv v10, v8, v9
122 ; V128-NEXT: li a0, -1
123 ; V128-NEXT: vwmaccu.vx v10, a0, v9
124 ; V128-NEXT: vmv1r.v v8, v10
127 ; V512-LABEL: interleave_v4i16:
129 ; V512-NEXT: vsetivli zero, 4, e16, mf4, ta, ma
130 ; V512-NEXT: vwaddu.vv v10, v8, v9
131 ; V512-NEXT: li a0, -1
132 ; V512-NEXT: vwmaccu.vx v10, a0, v9
133 ; V512-NEXT: vmv1r.v v8, v10
135 %a = shufflevector <4 x i16> %x, <4 x i16> %y, <8 x i32> <i32 0, i32 4, i32 undef, i32 5, i32 2, i32 undef, i32 3, i32 7>
139 define <8 x i32> @interleave_v4i32(<4 x i32> %x, <4 x i32> %y) {
140 ; V128-LABEL: interleave_v4i32:
142 ; V128-NEXT: vsetivli zero, 4, e32, m1, ta, ma
143 ; V128-NEXT: vwaddu.vv v10, v8, v9
144 ; V128-NEXT: li a0, -1
145 ; V128-NEXT: vwmaccu.vx v10, a0, v9
146 ; V128-NEXT: vmv2r.v v8, v10
149 ; V512-LABEL: interleave_v4i32:
151 ; V512-NEXT: vsetivli zero, 4, e32, mf2, ta, ma
152 ; V512-NEXT: vwaddu.vv v10, v8, v9
153 ; V512-NEXT: li a0, -1
154 ; V512-NEXT: vwmaccu.vx v10, a0, v9
155 ; V512-NEXT: vmv1r.v v8, v10
157 %a = shufflevector <4 x i32> %x, <4 x i32> %y, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
161 ; %y should be slid down by 2
162 define <4 x i32> @interleave_v4i32_offset_2(<4 x i32> %x, <4 x i32> %y) {
163 ; V128-LABEL: interleave_v4i32_offset_2:
165 ; V128-NEXT: vsetivli zero, 2, e32, m1, ta, ma
166 ; V128-NEXT: vslidedown.vi v10, v9, 2
167 ; V128-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
168 ; V128-NEXT: vwaddu.vv v9, v8, v10
169 ; V128-NEXT: li a0, -1
170 ; V128-NEXT: vwmaccu.vx v9, a0, v10
171 ; V128-NEXT: vmv1r.v v8, v9
174 ; V512-LABEL: interleave_v4i32_offset_2:
176 ; V512-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
177 ; V512-NEXT: vslidedown.vi v10, v9, 2
178 ; V512-NEXT: vwaddu.vv v9, v8, v10
179 ; V512-NEXT: li a0, -1
180 ; V512-NEXT: vwmaccu.vx v9, a0, v10
181 ; V512-NEXT: vmv1r.v v8, v9
183 %a = shufflevector <4 x i32> %x, <4 x i32> %y, <4 x i32> <i32 0, i32 6, i32 1, i32 7>
187 ; %y should be slid down by 1
188 define <4 x i32> @interleave_v4i32_offset_1(<4 x i32> %x, <4 x i32> %y) {
189 ; V128-LABEL: interleave_v4i32_offset_1:
191 ; V128-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
192 ; V128-NEXT: vwaddu.vv v10, v8, v8
193 ; V128-NEXT: li a0, -1
194 ; V128-NEXT: vwmaccu.vx v10, a0, v8
195 ; V128-NEXT: vsetivli zero, 4, e32, m1, ta, mu
196 ; V128-NEXT: vid.v v8
197 ; V128-NEXT: vsrl.vi v8, v8, 1
198 ; V128-NEXT: vmv.v.i v0, 10
199 ; V128-NEXT: vadd.vi v8, v8, 1
200 ; V128-NEXT: vrgather.vv v10, v9, v8, v0.t
201 ; V128-NEXT: vmv.v.v v8, v10
204 ; V512-LABEL: interleave_v4i32_offset_1:
206 ; V512-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
207 ; V512-NEXT: vwaddu.vv v10, v8, v8
208 ; V512-NEXT: li a0, -1
209 ; V512-NEXT: vwmaccu.vx v10, a0, v8
210 ; V512-NEXT: vsetivli zero, 4, e32, mf2, ta, mu
211 ; V512-NEXT: vid.v v8
212 ; V512-NEXT: vsrl.vi v8, v8, 1
213 ; V512-NEXT: vmv.v.i v0, 10
214 ; V512-NEXT: vadd.vi v8, v8, 1
215 ; V512-NEXT: vrgather.vv v10, v9, v8, v0.t
216 ; V512-NEXT: vmv1r.v v8, v10
218 %a = shufflevector <4 x i32> %x, <4 x i32> %y, <4 x i32> <i32 0, i32 5, i32 1, i32 6>
222 define <16 x i8> @interleave_v8i8(<8 x i8> %x, <8 x i8> %y) {
223 ; V128-LABEL: interleave_v8i8:
225 ; V128-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
226 ; V128-NEXT: vwaddu.vv v10, v8, v9
227 ; V128-NEXT: li a0, -1
228 ; V128-NEXT: vwmaccu.vx v10, a0, v9
229 ; V128-NEXT: vmv1r.v v8, v10
232 ; V512-LABEL: interleave_v8i8:
234 ; V512-NEXT: vsetivli zero, 8, e8, mf8, ta, ma
235 ; V512-NEXT: vwaddu.vv v10, v8, v9
236 ; V512-NEXT: li a0, -1
237 ; V512-NEXT: vwmaccu.vx v10, a0, v9
238 ; V512-NEXT: vmv1r.v v8, v10
240 %a = shufflevector <8 x i8> %x, <8 x i8> %y, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
244 ; Vector order switched for coverage.
245 define <16 x i16> @interleave_v8i16(<8 x i16> %x, <8 x i16> %y) {
246 ; V128-LABEL: interleave_v8i16:
248 ; V128-NEXT: vsetivli zero, 8, e16, m1, ta, ma
249 ; V128-NEXT: vwaddu.vv v10, v9, v8
250 ; V128-NEXT: li a0, -1
251 ; V128-NEXT: vwmaccu.vx v10, a0, v8
252 ; V128-NEXT: vmv2r.v v8, v10
255 ; V512-LABEL: interleave_v8i16:
257 ; V512-NEXT: vsetivli zero, 8, e16, mf4, ta, ma
258 ; V512-NEXT: vwaddu.vv v10, v9, v8
259 ; V512-NEXT: li a0, -1
260 ; V512-NEXT: vwmaccu.vx v10, a0, v8
261 ; V512-NEXT: vmv1r.v v8, v10
263 %a = shufflevector <8 x i16> %x, <8 x i16> %y, <16 x i32> <i32 8, i32 0, i32 9, i32 1, i32 10, i32 2, i32 11, i32 3, i32 12, i32 4, i32 13, i32 5, i32 14, i32 6, i32 15, i32 7>
267 define <16 x i32> @interleave_v8i32(<8 x i32> %x, <8 x i32> %y) {
268 ; V128-LABEL: interleave_v8i32:
270 ; V128-NEXT: vsetivli zero, 8, e32, m2, ta, ma
271 ; V128-NEXT: vwaddu.vv v12, v8, v10
272 ; V128-NEXT: li a0, -1
273 ; V128-NEXT: vwmaccu.vx v12, a0, v10
274 ; V128-NEXT: vmv4r.v v8, v12
277 ; V512-LABEL: interleave_v8i32:
279 ; V512-NEXT: vsetivli zero, 8, e32, mf2, ta, ma
280 ; V512-NEXT: vwaddu.vv v10, v8, v9
281 ; V512-NEXT: li a0, -1
282 ; V512-NEXT: vwmaccu.vx v10, a0, v9
283 ; V512-NEXT: vmv1r.v v8, v10
285 %a = shufflevector <8 x i32> %x, <8 x i32> %y, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
289 define <32 x i8> @interleave_v16i8(<16 x i8> %x, <16 x i8> %y) {
290 ; V128-LABEL: interleave_v16i8:
292 ; V128-NEXT: vsetivli zero, 16, e8, m1, ta, ma
293 ; V128-NEXT: vwaddu.vv v10, v8, v9
294 ; V128-NEXT: li a0, -1
295 ; V128-NEXT: vwmaccu.vx v10, a0, v9
296 ; V128-NEXT: vmv2r.v v8, v10
299 ; V512-LABEL: interleave_v16i8:
301 ; V512-NEXT: vsetivli zero, 16, e8, mf4, ta, ma
302 ; V512-NEXT: vwaddu.vv v10, v8, v9
303 ; V512-NEXT: li a0, -1
304 ; V512-NEXT: vwmaccu.vx v10, a0, v9
305 ; V512-NEXT: vmv1r.v v8, v10
307 %a = shufflevector <16 x i8> %x, <16 x i8> %y, <32 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
311 define <32 x i16> @interleave_v16i16(<16 x i16> %x, <16 x i16> %y) {
312 ; V128-LABEL: interleave_v16i16:
314 ; V128-NEXT: vsetivli zero, 16, e16, m2, ta, ma
315 ; V128-NEXT: vwaddu.vv v12, v8, v10
316 ; V128-NEXT: li a0, -1
317 ; V128-NEXT: vwmaccu.vx v12, a0, v10
318 ; V128-NEXT: vmv4r.v v8, v12
321 ; V512-LABEL: interleave_v16i16:
323 ; V512-NEXT: vsetivli zero, 16, e16, mf2, ta, ma
324 ; V512-NEXT: vwaddu.vv v10, v8, v9
325 ; V512-NEXT: li a0, -1
326 ; V512-NEXT: vwmaccu.vx v10, a0, v9
327 ; V512-NEXT: vmv1r.v v8, v10
329 %a = shufflevector <16 x i16> %x, <16 x i16> %y, <32 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
333 define <32 x i32> @interleave_v16i32(<16 x i32> %x, <16 x i32> %y) {
334 ; V128-LABEL: interleave_v16i32:
336 ; V128-NEXT: vsetivli zero, 16, e32, m4, ta, ma
337 ; V128-NEXT: vwaddu.vv v16, v8, v12
338 ; V128-NEXT: li a0, -1
339 ; V128-NEXT: vwmaccu.vx v16, a0, v12
340 ; V128-NEXT: vmv8r.v v8, v16
343 ; V512-LABEL: interleave_v16i32:
345 ; V512-NEXT: vsetivli zero, 16, e32, m1, ta, ma
346 ; V512-NEXT: vwaddu.vv v10, v8, v9
347 ; V512-NEXT: li a0, -1
348 ; V512-NEXT: vwmaccu.vx v10, a0, v9
349 ; V512-NEXT: vmv2r.v v8, v10
351 %a = shufflevector <16 x i32> %x, <16 x i32> %y, <32 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
355 define <64 x i8> @interleave_v32i8(<32 x i8> %x, <32 x i8> %y) {
356 ; V128-LABEL: interleave_v32i8:
358 ; V128-NEXT: li a0, 32
359 ; V128-NEXT: vsetvli zero, a0, e8, m2, ta, ma
360 ; V128-NEXT: vwaddu.vv v12, v8, v10
361 ; V128-NEXT: li a0, -1
362 ; V128-NEXT: vwmaccu.vx v12, a0, v10
363 ; V128-NEXT: vmv4r.v v8, v12
366 ; V512-LABEL: interleave_v32i8:
368 ; V512-NEXT: li a0, 32
369 ; V512-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
370 ; V512-NEXT: vwaddu.vv v10, v8, v9
371 ; V512-NEXT: li a0, -1
372 ; V512-NEXT: vwmaccu.vx v10, a0, v9
373 ; V512-NEXT: vmv1r.v v8, v10
375 %a = shufflevector <32 x i8> %x, <32 x i8> %y, <64 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
379 define <64 x i16> @interleave_v32i16(<32 x i16> %x, <32 x i16> %y) {
380 ; V128-LABEL: interleave_v32i16:
382 ; V128-NEXT: li a0, 32
383 ; V128-NEXT: vsetvli zero, a0, e16, m4, ta, ma
384 ; V128-NEXT: vwaddu.vv v16, v8, v12
385 ; V128-NEXT: li a0, -1
386 ; V128-NEXT: vwmaccu.vx v16, a0, v12
387 ; V128-NEXT: vmv8r.v v8, v16
390 ; V512-LABEL: interleave_v32i16:
392 ; V512-NEXT: li a0, 32
393 ; V512-NEXT: vsetvli zero, a0, e16, m1, ta, ma
394 ; V512-NEXT: vwaddu.vv v10, v8, v9
395 ; V512-NEXT: li a0, -1
396 ; V512-NEXT: vwmaccu.vx v10, a0, v9
397 ; V512-NEXT: vmv2r.v v8, v10
399 %a = shufflevector <32 x i16> %x, <32 x i16> %y, <64 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
403 define <64 x i32> @interleave_v32i32(<32 x i32> %x, <32 x i32> %y) {
404 ; V128-LABEL: interleave_v32i32:
406 ; V128-NEXT: addi sp, sp, -16
407 ; V128-NEXT: .cfi_def_cfa_offset 16
408 ; V128-NEXT: csrr a0, vlenb
409 ; V128-NEXT: slli a0, a0, 3
410 ; V128-NEXT: sub sp, sp, a0
411 ; V128-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 8 * vlenb
412 ; V128-NEXT: vmv8r.v v0, v16
413 ; V128-NEXT: addi a0, sp, 16
414 ; V128-NEXT: vs8r.v v16, (a0) # Unknown-size Folded Spill
415 ; V128-NEXT: vmv8r.v v16, v8
416 ; V128-NEXT: vsetivli zero, 16, e32, m8, ta, ma
417 ; V128-NEXT: vslidedown.vi v8, v0, 16
418 ; V128-NEXT: vsetivli zero, 16, e32, m4, ta, ma
419 ; V128-NEXT: vwaddu.vv v24, v0, v8
420 ; V128-NEXT: li a0, -1
421 ; V128-NEXT: vwmaccu.vx v24, a0, v8
422 ; V128-NEXT: vsetivli zero, 16, e32, m8, ta, ma
423 ; V128-NEXT: vslidedown.vi v0, v16, 16
424 ; V128-NEXT: vsetivli zero, 16, e32, m4, ta, ma
425 ; V128-NEXT: vwaddu.vv v8, v0, v16
426 ; V128-NEXT: vwmaccu.vx v8, a0, v16
427 ; V128-NEXT: lui a1, 699051
428 ; V128-NEXT: addi a1, a1, -1366
429 ; V128-NEXT: vmv.s.x v0, a1
430 ; V128-NEXT: li a1, 32
431 ; V128-NEXT: vsetvli zero, a1, e32, m8, ta, ma
432 ; V128-NEXT: vmerge.vvm v24, v8, v24, v0
433 ; V128-NEXT: addi a1, sp, 16
434 ; V128-NEXT: vl8r.v v8, (a1) # Unknown-size Folded Reload
435 ; V128-NEXT: vsetivli zero, 16, e32, m4, ta, ma
436 ; V128-NEXT: vwaddu.vv v0, v16, v8
437 ; V128-NEXT: vwmaccu.vx v0, a0, v8
438 ; V128-NEXT: vmv8r.v v8, v0
439 ; V128-NEXT: vmv8r.v v16, v24
440 ; V128-NEXT: csrr a0, vlenb
441 ; V128-NEXT: slli a0, a0, 3
442 ; V128-NEXT: add sp, sp, a0
443 ; V128-NEXT: addi sp, sp, 16
446 ; V512-LABEL: interleave_v32i32:
448 ; V512-NEXT: li a0, 32
449 ; V512-NEXT: vsetvli zero, a0, e32, m2, ta, ma
450 ; V512-NEXT: vwaddu.vv v12, v8, v10
451 ; V512-NEXT: li a0, -1
452 ; V512-NEXT: vwmaccu.vx v12, a0, v10
453 ; V512-NEXT: vmv4r.v v8, v12
455 %a = shufflevector <32 x i32> %x, <32 x i32> %y, <64 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
459 define <4 x i8> @unary_interleave_v4i8(<4 x i8> %x) {
460 ; V128-LABEL: unary_interleave_v4i8:
462 ; V128-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
463 ; V128-NEXT: vslidedown.vi v10, v8, 2
464 ; V128-NEXT: vsetivli zero, 2, e8, mf8, ta, ma
465 ; V128-NEXT: vwaddu.vv v9, v8, v10
466 ; V128-NEXT: li a0, -1
467 ; V128-NEXT: vwmaccu.vx v9, a0, v10
468 ; V128-NEXT: vmv1r.v v8, v9
471 ; V512-LABEL: unary_interleave_v4i8:
473 ; V512-NEXT: vsetivli zero, 2, e8, mf8, ta, ma
474 ; V512-NEXT: vslidedown.vi v10, v8, 2
475 ; V512-NEXT: vwaddu.vv v9, v8, v10
476 ; V512-NEXT: li a0, -1
477 ; V512-NEXT: vwmaccu.vx v9, a0, v10
478 ; V512-NEXT: vmv1r.v v8, v9
480 %a = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
484 ; This shouldn't be interleaved
485 define <4 x i8> @unary_interleave_v4i8_invalid(<4 x i8> %x) {
486 ; V128-LABEL: unary_interleave_v4i8_invalid:
488 ; V128-NEXT: lui a0, 16
489 ; V128-NEXT: addi a0, a0, 768
490 ; V128-NEXT: vsetivli zero, 4, e32, m1, ta, ma
491 ; V128-NEXT: vmv.s.x v10, a0
492 ; V128-NEXT: vsetvli zero, zero, e8, mf4, ta, ma
493 ; V128-NEXT: vrgather.vv v9, v8, v10
494 ; V128-NEXT: vmv1r.v v8, v9
497 ; V512-LABEL: unary_interleave_v4i8_invalid:
499 ; V512-NEXT: lui a0, 16
500 ; V512-NEXT: addi a0, a0, 768
501 ; V512-NEXT: vsetivli zero, 4, e32, m1, ta, ma
502 ; V512-NEXT: vmv.s.x v10, a0
503 ; V512-NEXT: vsetivli zero, 4, e8, mf8, ta, ma
504 ; V512-NEXT: vrgather.vv v9, v8, v10
505 ; V512-NEXT: vmv1r.v v8, v9
507 %a = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 0, i32 3, i32 1, i32 4>
511 define <4 x i16> @unary_interleave_v4i16(<4 x i16> %x) {
512 ; V128-LABEL: unary_interleave_v4i16:
514 ; V128-NEXT: vsetivli zero, 2, e16, mf2, ta, ma
515 ; V128-NEXT: vslidedown.vi v10, v8, 2
516 ; V128-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
517 ; V128-NEXT: vwaddu.vv v9, v8, v10
518 ; V128-NEXT: li a0, -1
519 ; V128-NEXT: vwmaccu.vx v9, a0, v10
520 ; V128-NEXT: vmv1r.v v8, v9
523 ; V512-LABEL: unary_interleave_v4i16:
525 ; V512-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
526 ; V512-NEXT: vslidedown.vi v10, v8, 2
527 ; V512-NEXT: vwaddu.vv v9, v8, v10
528 ; V512-NEXT: li a0, -1
529 ; V512-NEXT: vwmaccu.vx v9, a0, v10
530 ; V512-NEXT: vmv1r.v v8, v9
532 %a = shufflevector <4 x i16> %x, <4 x i16> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
536 define <4 x i32> @unary_interleave_v4i32(<4 x i32> %x) {
537 ; V128-LABEL: unary_interleave_v4i32:
539 ; V128-NEXT: vsetivli zero, 2, e32, m1, ta, ma
540 ; V128-NEXT: vslidedown.vi v10, v8, 2
541 ; V128-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
542 ; V128-NEXT: vwaddu.vv v9, v8, v10
543 ; V128-NEXT: li a0, -1
544 ; V128-NEXT: vwmaccu.vx v9, a0, v10
545 ; V128-NEXT: vmv1r.v v8, v9
548 ; V512-LABEL: unary_interleave_v4i32:
550 ; V512-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
551 ; V512-NEXT: vslidedown.vi v10, v8, 2
552 ; V512-NEXT: vwaddu.vv v9, v8, v10
553 ; V512-NEXT: li a0, -1
554 ; V512-NEXT: vwmaccu.vx v9, a0, v10
555 ; V512-NEXT: vmv1r.v v8, v9
557 %a = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
561 ; FIXME: Is there better codegen we can do here?
562 define <4 x i64> @unary_interleave_v4i64(<4 x i64> %x) {
563 ; V128-LABEL: unary_interleave_v4i64:
565 ; V128-NEXT: lui a0, 12304
566 ; V128-NEXT: addi a0, a0, 512
567 ; V128-NEXT: vsetivli zero, 4, e32, m1, ta, ma
568 ; V128-NEXT: vmv.s.x v10, a0
569 ; V128-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
570 ; V128-NEXT: vsext.vf2 v12, v10
571 ; V128-NEXT: vsetvli zero, zero, e64, m2, ta, ma
572 ; V128-NEXT: vrgatherei16.vv v10, v8, v12
573 ; V128-NEXT: vmv.v.v v8, v10
576 ; RV32-V512-LABEL: unary_interleave_v4i64:
577 ; RV32-V512: # %bb.0:
578 ; RV32-V512-NEXT: lui a0, 12304
579 ; RV32-V512-NEXT: addi a0, a0, 512
580 ; RV32-V512-NEXT: vsetivli zero, 4, e32, m1, ta, ma
581 ; RV32-V512-NEXT: vmv.s.x v9, a0
582 ; RV32-V512-NEXT: vsetivli zero, 4, e16, mf4, ta, ma
583 ; RV32-V512-NEXT: vsext.vf2 v10, v9
584 ; RV32-V512-NEXT: vsetvli zero, zero, e64, m1, ta, ma
585 ; RV32-V512-NEXT: vrgatherei16.vv v9, v8, v10
586 ; RV32-V512-NEXT: vmv.v.v v8, v9
587 ; RV32-V512-NEXT: ret
589 ; RV64-V512-LABEL: unary_interleave_v4i64:
590 ; RV64-V512: # %bb.0:
591 ; RV64-V512-NEXT: lui a0, 12304
592 ; RV64-V512-NEXT: addi a0, a0, 512
593 ; RV64-V512-NEXT: vsetivli zero, 4, e64, m1, ta, ma
594 ; RV64-V512-NEXT: vmv.s.x v9, a0
595 ; RV64-V512-NEXT: vsext.vf8 v10, v9
596 ; RV64-V512-NEXT: vrgather.vv v9, v8, v10
597 ; RV64-V512-NEXT: vmv.v.v v8, v9
598 ; RV64-V512-NEXT: ret
599 %a = shufflevector <4 x i64> %x, <4 x i64> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
603 define <8 x i8> @unary_interleave_v8i8(<8 x i8> %x) {
604 ; V128-LABEL: unary_interleave_v8i8:
606 ; V128-NEXT: vsetivli zero, 4, e8, mf2, ta, ma
607 ; V128-NEXT: vslidedown.vi v10, v8, 4
608 ; V128-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
609 ; V128-NEXT: vwaddu.vv v9, v8, v10
610 ; V128-NEXT: li a0, -1
611 ; V128-NEXT: vwmaccu.vx v9, a0, v10
612 ; V128-NEXT: vmv1r.v v8, v9
615 ; V512-LABEL: unary_interleave_v8i8:
617 ; V512-NEXT: vsetivli zero, 4, e8, mf8, ta, ma
618 ; V512-NEXT: vslidedown.vi v10, v8, 4
619 ; V512-NEXT: vwaddu.vv v9, v8, v10
620 ; V512-NEXT: li a0, -1
621 ; V512-NEXT: vwmaccu.vx v9, a0, v10
622 ; V512-NEXT: vmv1r.v v8, v9
624 %a = shufflevector <8 x i8> %x, <8 x i8> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 undef, i32 6, i32 3, i32 7>
628 define <8 x i16> @unary_interleave_v8i16(<8 x i16> %x) {
629 ; V128-LABEL: unary_interleave_v8i16:
631 ; V128-NEXT: vsetivli zero, 4, e16, m1, ta, ma
632 ; V128-NEXT: vslidedown.vi v10, v8, 4
633 ; V128-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
634 ; V128-NEXT: vwaddu.vv v9, v10, v8
635 ; V128-NEXT: li a0, -1
636 ; V128-NEXT: vwmaccu.vx v9, a0, v8
637 ; V128-NEXT: vmv1r.v v8, v9
640 ; V512-LABEL: unary_interleave_v8i16:
642 ; V512-NEXT: vsetivli zero, 4, e16, mf4, ta, ma
643 ; V512-NEXT: vslidedown.vi v10, v8, 4
644 ; V512-NEXT: vwaddu.vv v9, v10, v8
645 ; V512-NEXT: li a0, -1
646 ; V512-NEXT: vwmaccu.vx v9, a0, v8
647 ; V512-NEXT: vmv1r.v v8, v9
649 %a = shufflevector <8 x i16> %x, <8 x i16> poison, <8 x i32> <i32 4, i32 undef, i32 5, i32 1, i32 6, i32 2, i32 7, i32 3>
653 define <8 x i32> @unary_interleave_v8i32(<8 x i32> %x) {
654 ; V128-LABEL: unary_interleave_v8i32:
656 ; V128-NEXT: vsetivli zero, 4, e32, m2, ta, ma
657 ; V128-NEXT: vslidedown.vi v12, v8, 4
658 ; V128-NEXT: vsetivli zero, 4, e32, m1, ta, ma
659 ; V128-NEXT: vwaddu.vv v10, v8, v12
660 ; V128-NEXT: li a0, -1
661 ; V128-NEXT: vwmaccu.vx v10, a0, v12
662 ; V128-NEXT: vmv2r.v v8, v10
665 ; V512-LABEL: unary_interleave_v8i32:
667 ; V512-NEXT: vsetivli zero, 4, e32, mf2, ta, ma
668 ; V512-NEXT: vslidedown.vi v10, v8, 4
669 ; V512-NEXT: vwaddu.vv v9, v8, v10
670 ; V512-NEXT: li a0, -1
671 ; V512-NEXT: vwmaccu.vx v9, a0, v10
672 ; V512-NEXT: vmv1r.v v8, v9
674 %a = shufflevector <8 x i32> %x, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
678 ; This interleaves the first 2 elements of a vector in opposite order. With
679 ; undefs for the remaining elements. We use to miscompile this.
680 define <4 x i8> @unary_interleave_10uu_v4i8(<4 x i8> %x) {
681 ; CHECK-LABEL: unary_interleave_10uu_v4i8:
683 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
684 ; CHECK-NEXT: vsrl.vi v9, v8, 8
685 ; CHECK-NEXT: vsll.vi v8, v8, 8
686 ; CHECK-NEXT: vor.vv v8, v8, v9
688 %a = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 1, i32 0, i32 undef, i32 undef>
692 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: