1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=riscv32 -mattr=+v,+zvfh,+zvfbfmin,+m | FileCheck --check-prefixes=CHECK,RV32 %s
3 ; RUN: llc < %s -mtriple=riscv64 -mattr=+v,+zvfh,+zvfbfmin,+m | FileCheck --check-prefixes=CHECK,RV64 %s
4 ; RUN: llc < %s -mtriple=riscv32 -mattr=+v,+zvfhmin,+zvfbfmin,+m | FileCheck --check-prefixes=CHECK,RV32 %s
5 ; RUN: llc < %s -mtriple=riscv64 -mattr=+v,+zvfhmin,+zvfbfmin,+m | FileCheck --check-prefixes=CHECK,RV64 %s
9 define {<vscale x 16 x i1>, <vscale x 16 x i1>} @vector_deinterleave_load_nxv16i1_nxv32i1(ptr %p) {
10 ; CHECK-LABEL: vector_deinterleave_load_nxv16i1_nxv32i1:
12 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
13 ; CHECK-NEXT: vlm.v v8, (a0)
14 ; CHECK-NEXT: csrr a0, vlenb
15 ; CHECK-NEXT: srli a0, a0, 2
16 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
17 ; CHECK-NEXT: vslidedown.vx v0, v8, a0
18 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
19 ; CHECK-NEXT: vmv.v.i v10, 0
20 ; CHECK-NEXT: vmerge.vim v14, v10, 1, v0
21 ; CHECK-NEXT: vmv1r.v v0, v8
22 ; CHECK-NEXT: vmerge.vim v12, v10, 1, v0
23 ; CHECK-NEXT: vnsrl.wi v8, v12, 0
24 ; CHECK-NEXT: vnsrl.wi v10, v12, 8
25 ; CHECK-NEXT: vmsne.vi v0, v8, 0
26 ; CHECK-NEXT: vmsne.vi v8, v10, 0
28 %vec = load <vscale x 32 x i1>, ptr %p
29 %retval = call {<vscale x 16 x i1>, <vscale x 16 x i1>} @llvm.vector.deinterleave2.nxv32i1(<vscale x 32 x i1> %vec)
30 ret {<vscale x 16 x i1>, <vscale x 16 x i1>} %retval
33 define {<vscale x 16 x i8>, <vscale x 16 x i8>} @vector_deinterleave_load_nxv16i8_nxv32i8(ptr %p) {
34 ; CHECK-LABEL: vector_deinterleave_load_nxv16i8_nxv32i8:
36 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
37 ; CHECK-NEXT: vlseg2e8.v v8, (a0)
39 %vec = load <vscale x 32 x i8>, ptr %p
40 %retval = call {<vscale x 16 x i8>, <vscale x 16 x i8>} @llvm.vector.deinterleave2.nxv32i8(<vscale x 32 x i8> %vec)
41 ret {<vscale x 16 x i8>, <vscale x 16 x i8>} %retval
44 ; Shouldn't be lowered to vlseg because it's unaligned
45 define {<vscale x 8 x i16>, <vscale x 8 x i16>} @vector_deinterleave_load_nxv8i16_nxv16i16_align1(ptr %p) {
46 ; CHECK-LABEL: vector_deinterleave_load_nxv8i16_nxv16i16_align1:
48 ; CHECK-NEXT: vl4r.v v12, (a0)
49 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
50 ; CHECK-NEXT: vnsrl.wi v8, v12, 0
51 ; CHECK-NEXT: vnsrl.wi v10, v12, 16
53 %vec = load <vscale x 16 x i16>, ptr %p, align 1
54 %retval = call {<vscale x 8 x i16>, <vscale x 8 x i16>} @llvm.vector.deinterleave2.nxv16i16(<vscale x 16 x i16> %vec)
55 ret {<vscale x 8 x i16>, <vscale x 8 x i16>} %retval
58 define {<vscale x 8 x i16>, <vscale x 8 x i16>} @vector_deinterleave_load_nxv8i16_nxv16i16(ptr %p) {
59 ; CHECK-LABEL: vector_deinterleave_load_nxv8i16_nxv16i16:
61 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
62 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
64 %vec = load <vscale x 16 x i16>, ptr %p
65 %retval = call {<vscale x 8 x i16>, <vscale x 8 x i16>} @llvm.vector.deinterleave2.nxv16i16(<vscale x 16 x i16> %vec)
66 ret {<vscale x 8 x i16>, <vscale x 8 x i16>} %retval
69 define {<vscale x 4 x i32>, <vscale x 4 x i32>} @vector_deinterleave_load_nxv4i32_nxvv8i32(ptr %p) {
70 ; CHECK-LABEL: vector_deinterleave_load_nxv4i32_nxvv8i32:
72 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
73 ; CHECK-NEXT: vlseg2e32.v v8, (a0)
75 %vec = load <vscale x 8 x i32>, ptr %p
76 %retval = call {<vscale x 4 x i32>, <vscale x 4 x i32>} @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %vec)
77 ret {<vscale x 4 x i32>, <vscale x 4 x i32>} %retval
80 define {<vscale x 2 x i64>, <vscale x 2 x i64>} @vector_deinterleave_load_nxv2i64_nxv4i64(ptr %p) {
81 ; CHECK-LABEL: vector_deinterleave_load_nxv2i64_nxv4i64:
83 ; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma
84 ; CHECK-NEXT: vlseg2e64.v v8, (a0)
86 %vec = load <vscale x 4 x i64>, ptr %p
87 %retval = call {<vscale x 2 x i64>, <vscale x 2 x i64>} @llvm.vector.deinterleave2.nxv4i64(<vscale x 4 x i64> %vec)
88 ret {<vscale x 2 x i64>, <vscale x 2 x i64>} %retval
91 define {<vscale x 4 x i64>, <vscale x 4 x i64>} @vector_deinterleave_load_nxv4i64_nxv8i64(ptr %p) {
92 ; CHECK-LABEL: vector_deinterleave_load_nxv4i64_nxv8i64:
94 ; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma
95 ; CHECK-NEXT: vlseg2e64.v v8, (a0)
97 %vec = load <vscale x 8 x i64>, ptr %p
98 %retval = call {<vscale x 4 x i64>, <vscale x 4 x i64>} @llvm.vector.deinterleave2.nxv8i64(<vscale x 8 x i64> %vec)
99 ret {<vscale x 4 x i64>, <vscale x 4 x i64>} %retval
102 ; This shouldn't be lowered to a vlseg because EMUL * NFIELDS >= 8
103 define {<vscale x 8 x i64>, <vscale x 8 x i64>} @vector_deinterleave_load_nxv8i64_nxv16i64(ptr %p) {
104 ; CHECK-LABEL: vector_deinterleave_load_nxv8i64_nxv16i64:
106 ; CHECK-NEXT: addi sp, sp, -16
107 ; CHECK-NEXT: .cfi_def_cfa_offset 16
108 ; CHECK-NEXT: csrr a1, vlenb
109 ; CHECK-NEXT: slli a1, a1, 4
110 ; CHECK-NEXT: sub sp, sp, a1
111 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 16 * vlenb
112 ; CHECK-NEXT: li a1, 85
113 ; CHECK-NEXT: vsetvli a2, zero, e8, mf8, ta, ma
114 ; CHECK-NEXT: vmv.v.x v16, a1
115 ; CHECK-NEXT: csrr a1, vlenb
116 ; CHECK-NEXT: vl8re64.v v24, (a0)
117 ; CHECK-NEXT: slli a1, a1, 3
118 ; CHECK-NEXT: add a0, a0, a1
119 ; CHECK-NEXT: li a1, 170
120 ; CHECK-NEXT: vl8re64.v v0, (a0)
121 ; CHECK-NEXT: vmv.v.x v17, a1
122 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
123 ; CHECK-NEXT: vcompress.vm v8, v24, v16
124 ; CHECK-NEXT: vmv1r.v v12, v16
125 ; CHECK-NEXT: vmv1r.v v13, v17
126 ; CHECK-NEXT: vcompress.vm v16, v24, v13
127 ; CHECK-NEXT: vcompress.vm v24, v0, v12
128 ; CHECK-NEXT: addi a0, sp, 16
129 ; CHECK-NEXT: vs8r.v v24, (a0) # Unknown-size Folded Spill
130 ; CHECK-NEXT: vcompress.vm v24, v0, v13
131 ; CHECK-NEXT: csrr a0, vlenb
132 ; CHECK-NEXT: slli a0, a0, 3
133 ; CHECK-NEXT: add a0, sp, a0
134 ; CHECK-NEXT: addi a0, a0, 16
135 ; CHECK-NEXT: vs8r.v v24, (a0) # Unknown-size Folded Spill
136 ; CHECK-NEXT: addi a0, sp, 16
137 ; CHECK-NEXT: vl8r.v v24, (a0) # Unknown-size Folded Reload
138 ; CHECK-NEXT: vmv4r.v v12, v24
139 ; CHECK-NEXT: csrr a0, vlenb
140 ; CHECK-NEXT: slli a0, a0, 3
141 ; CHECK-NEXT: add a0, sp, a0
142 ; CHECK-NEXT: addi a0, a0, 16
143 ; CHECK-NEXT: vl8r.v v24, (a0) # Unknown-size Folded Reload
144 ; CHECK-NEXT: vmv4r.v v20, v24
145 ; CHECK-NEXT: csrr a0, vlenb
146 ; CHECK-NEXT: slli a0, a0, 4
147 ; CHECK-NEXT: add sp, sp, a0
148 ; CHECK-NEXT: .cfi_def_cfa sp, 16
149 ; CHECK-NEXT: addi sp, sp, 16
150 ; CHECK-NEXT: .cfi_def_cfa_offset 0
152 %vec = load <vscale x 16 x i64>, ptr %p
153 %retval = call {<vscale x 8 x i64>, <vscale x 8 x i64>} @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %vec)
154 ret {<vscale x 8 x i64>, <vscale x 8 x i64>} %retval
157 declare {<vscale x 16 x i1>, <vscale x 16 x i1>} @llvm.vector.deinterleave2.nxv32i1(<vscale x 32 x i1>)
158 declare {<vscale x 16 x i8>, <vscale x 16 x i8>} @llvm.vector.deinterleave2.nxv32i8(<vscale x 32 x i8>)
159 declare {<vscale x 8 x i16>, <vscale x 8 x i16>} @llvm.vector.deinterleave2.nxv16i16(<vscale x 16 x i16>)
160 declare {<vscale x 4 x i32>, <vscale x 4 x i32>} @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32>)
161 declare {<vscale x 2 x i64>, <vscale x 2 x i64>} @llvm.vector.deinterleave2.nxv4i64(<vscale x 4 x i64>)
162 declare {<vscale x 4 x i64>, <vscale x 4 x i64>} @llvm.vector.deinterleave2.nxv8i64(<vscale x 8 x i64>)
163 declare {<vscale x 8 x i64>, <vscale x 8 x i64>} @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64>)
167 define {<vscale x 2 x bfloat>, <vscale x 2 x bfloat>} @vector_deinterleave_load_nxv2bf16_nxv4bf16(ptr %p) {
168 ; CHECK-LABEL: vector_deinterleave_load_nxv2bf16_nxv4bf16:
170 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
171 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
173 %vec = load <vscale x 4 x bfloat>, ptr %p
174 %retval = call {<vscale x 2 x bfloat>, <vscale x 2 x bfloat>} @llvm.vector.deinterleave2.nxv4bf16(<vscale x 4 x bfloat> %vec)
175 ret {<vscale x 2 x bfloat>, <vscale x 2 x bfloat>} %retval
178 define {<vscale x 4 x bfloat>, <vscale x 4 x bfloat>} @vector_deinterleave_load_nxv4bf16_nxv8bf16(ptr %p) {
179 ; CHECK-LABEL: vector_deinterleave_load_nxv4bf16_nxv8bf16:
181 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
182 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
184 %vec = load <vscale x 8 x bfloat>, ptr %p
185 %retval = call {<vscale x 4 x bfloat>, <vscale x 4 x bfloat>} @llvm.vector.deinterleave2.nxv8bf16(<vscale x 8 x bfloat> %vec)
186 ret {<vscale x 4 x bfloat>, <vscale x 4 x bfloat>} %retval
189 define {<vscale x 2 x half>, <vscale x 2 x half>} @vector_deinterleave_load_nxv2f16_nxv4f16(ptr %p) {
190 ; CHECK-LABEL: vector_deinterleave_load_nxv2f16_nxv4f16:
192 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
193 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
195 %vec = load <vscale x 4 x half>, ptr %p
196 %retval = call {<vscale x 2 x half>, <vscale x 2 x half>} @llvm.vector.deinterleave2.nxv4f16(<vscale x 4 x half> %vec)
197 ret {<vscale x 2 x half>, <vscale x 2 x half>} %retval
200 define {<vscale x 4 x half>, <vscale x 4 x half>} @vector_deinterleave_load_nxv4f16_nxv8f16(ptr %p) {
201 ; CHECK-LABEL: vector_deinterleave_load_nxv4f16_nxv8f16:
203 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
204 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
206 %vec = load <vscale x 8 x half>, ptr %p
207 %retval = call {<vscale x 4 x half>, <vscale x 4 x half>} @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %vec)
208 ret {<vscale x 4 x half>, <vscale x 4 x half>} %retval
211 define {<vscale x 2 x float>, <vscale x 2 x float>} @vector_deinterleave_load_nxv2f32_nxv4f32(ptr %p) {
212 ; CHECK-LABEL: vector_deinterleave_load_nxv2f32_nxv4f32:
214 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
215 ; CHECK-NEXT: vlseg2e32.v v8, (a0)
217 %vec = load <vscale x 4 x float>, ptr %p
218 %retval = call {<vscale x 2 x float>, <vscale x 2 x float>} @llvm.vector.deinterleave2.nxv4f32(<vscale x 4 x float> %vec)
219 ret {<vscale x 2 x float>, <vscale x 2 x float>} %retval
222 define {<vscale x 8 x bfloat>, <vscale x 8 x bfloat>} @vector_deinterleave_load_nxv8bf16_nxv16bf16(ptr %p) {
223 ; CHECK-LABEL: vector_deinterleave_load_nxv8bf16_nxv16bf16:
225 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
226 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
228 %vec = load <vscale x 16 x bfloat>, ptr %p
229 %retval = call {<vscale x 8 x bfloat>, <vscale x 8 x bfloat>} @llvm.vector.deinterleave2.nxv16bf16(<vscale x 16 x bfloat> %vec)
230 ret {<vscale x 8 x bfloat>, <vscale x 8 x bfloat>} %retval
233 define {<vscale x 8 x half>, <vscale x 8 x half>} @vector_deinterleave_load_nxv8f16_nxv16f16(ptr %p) {
234 ; CHECK-LABEL: vector_deinterleave_load_nxv8f16_nxv16f16:
236 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
237 ; CHECK-NEXT: vlseg2e16.v v8, (a0)
239 %vec = load <vscale x 16 x half>, ptr %p
240 %retval = call {<vscale x 8 x half>, <vscale x 8 x half>} @llvm.vector.deinterleave2.nxv16f16(<vscale x 16 x half> %vec)
241 ret {<vscale x 8 x half>, <vscale x 8 x half>} %retval
244 define {<vscale x 4 x float>, <vscale x 4 x float>} @vector_deinterleave_load_nxv4f32_nxv8f32(ptr %p) {
245 ; CHECK-LABEL: vector_deinterleave_load_nxv4f32_nxv8f32:
247 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
248 ; CHECK-NEXT: vlseg2e32.v v8, (a0)
250 %vec = load <vscale x 8 x float>, ptr %p
251 %retval = call {<vscale x 4 x float>, <vscale x 4 x float>} @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %vec)
252 ret {<vscale x 4 x float>, <vscale x 4 x float>} %retval
255 define {<vscale x 2 x double>, <vscale x 2 x double>} @vector_deinterleave_load_nxv2f64_nxv4f64(ptr %p) {
256 ; CHECK-LABEL: vector_deinterleave_load_nxv2f64_nxv4f64:
258 ; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma
259 ; CHECK-NEXT: vlseg2e64.v v8, (a0)
261 %vec = load <vscale x 4 x double>, ptr %p
262 %retval = call {<vscale x 2 x double>, <vscale x 2 x double>} @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %vec)
263 ret {<vscale x 2 x double>, <vscale x 2 x double>} %retval
266 define {<vscale x 2 x ptr>, <vscale x 2 x ptr>} @vector_deinterleave_load_nxv2p0_nxv4p0(ptr %p) {
267 ; RV32-LABEL: vector_deinterleave_load_nxv2p0_nxv4p0:
269 ; RV32-NEXT: vsetvli a1, zero, e32, m1, ta, ma
270 ; RV32-NEXT: vlseg2e32.v v8, (a0)
273 ; RV64-LABEL: vector_deinterleave_load_nxv2p0_nxv4p0:
275 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
276 ; RV64-NEXT: vlseg2e64.v v8, (a0)
278 %vec = load <vscale x 4 x ptr>, ptr %p
279 %retval = call {<vscale x 2 x ptr>, <vscale x 2 x ptr>} @llvm.vector.deinterleave2.nxv4p0(<vscale x 4 x ptr> %vec)
280 ret {<vscale x 2 x ptr>, <vscale x 2 x ptr>} %retval
283 declare {<vscale x 2 x half>,<vscale x 2 x half>} @llvm.vector.deinterleave2.nxv4f16(<vscale x 4 x half>)
284 declare {<vscale x 4 x half>, <vscale x 4 x half>} @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half>)
285 declare {<vscale x 2 x float>, <vscale x 2 x float>} @llvm.vector.deinterleave2.nxv4f32(<vscale x 4 x float>)
286 declare {<vscale x 8 x half>, <vscale x 8 x half>} @llvm.vector.deinterleave2.nxv16f16(<vscale x 16 x half>)
287 declare {<vscale x 4 x float>, <vscale x 4 x float>} @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float>)
288 declare {<vscale x 2 x double>, <vscale x 2 x double>} @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double>)
289 declare {<vscale x 2 x ptr>, <vscale x 2 x ptr>} @llvm.vector.deinterleave2.nxv4p0(<vscale x 4 x ptr>)