1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+m,+v -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv64 -mattr=+m,+v -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,RV64
5 declare i32 @llvm.experimental.get.vector.length.i16(i16, i32, i1)
6 declare i32 @llvm.experimental.get.vector.length.i32(i32, i32, i1)
7 declare i32 @llvm.experimental.get.vector.length.i64(i64, i32, i1)
9 define i32 @vector_length_i16(i16 zeroext %tc) {
10 ; CHECK-LABEL: vector_length_i16:
12 ; CHECK-NEXT: csrr a1, vlenb
13 ; CHECK-NEXT: srli a1, a1, 2
14 ; CHECK-NEXT: bltu a0, a1, .LBB0_2
15 ; CHECK-NEXT: # %bb.1:
16 ; CHECK-NEXT: mv a0, a1
17 ; CHECK-NEXT: .LBB0_2:
19 %a = call i32 @llvm.experimental.get.vector.length.i16(i16 %tc, i32 2, i1 true)
23 define i32 @vector_length_i32(i32 zeroext %tc) {
24 ; CHECK-LABEL: vector_length_i32:
26 ; CHECK-NEXT: vsetvli a0, a0, e8, mf4, ta, ma
28 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 2, i1 true)
32 define i32 @vector_length_XLen(iXLen zeroext %tc) {
33 ; CHECK-LABEL: vector_length_XLen:
35 ; CHECK-NEXT: vsetvli a0, a0, e8, mf4, ta, ma
37 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 2, i1 true)
41 define i32 @vector_length_i16_fixed(i16 zeroext %tc) {
42 ; CHECK-LABEL: vector_length_i16_fixed:
44 ; CHECK-NEXT: li a1, 2
45 ; CHECK-NEXT: bltu a0, a1, .LBB3_2
46 ; CHECK-NEXT: # %bb.1:
47 ; CHECK-NEXT: li a0, 2
48 ; CHECK-NEXT: .LBB3_2:
50 %a = call i32 @llvm.experimental.get.vector.length.i16(i16 %tc, i32 2, i1 false)
54 define i32 @vector_length_i32_fixed(i32 zeroext %tc) {
55 ; CHECK-LABEL: vector_length_i32_fixed:
57 ; CHECK-NEXT: li a1, 2
58 ; CHECK-NEXT: bltu a0, a1, .LBB4_2
59 ; CHECK-NEXT: # %bb.1:
60 ; CHECK-NEXT: li a0, 2
61 ; CHECK-NEXT: .LBB4_2:
63 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 2, i1 false)
67 define i32 @vector_length_XLen_fixed(iXLen zeroext %tc) {
68 ; CHECK-LABEL: vector_length_XLen_fixed:
70 ; CHECK-NEXT: li a1, 2
71 ; CHECK-NEXT: bltu a0, a1, .LBB5_2
72 ; CHECK-NEXT: # %bb.1:
73 ; CHECK-NEXT: li a0, 2
74 ; CHECK-NEXT: .LBB5_2:
76 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 2, i1 false)
80 define i32 @vector_length_vf1_i32(i32 zeroext %tc) {
81 ; CHECK-LABEL: vector_length_vf1_i32:
83 ; CHECK-NEXT: vsetvli a0, a0, e8, mf8, ta, ma
85 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 1, i1 true)
89 define i32 @vector_length_vf1_XLen(iXLen zeroext %tc) {
90 ; CHECK-LABEL: vector_length_vf1_XLen:
92 ; CHECK-NEXT: vsetvli a0, a0, e8, mf8, ta, ma
94 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 1, i1 true)
98 define i32 @vector_length_vf2_i32(i32 zeroext %tc) {
99 ; CHECK-LABEL: vector_length_vf2_i32:
101 ; CHECK-NEXT: vsetvli a0, a0, e8, mf4, ta, ma
103 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 2, i1 true)
107 define i32 @vector_length_vf2_XLen(iXLen zeroext %tc) {
108 ; CHECK-LABEL: vector_length_vf2_XLen:
110 ; CHECK-NEXT: vsetvli a0, a0, e8, mf4, ta, ma
112 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 2, i1 true)
116 define i32 @vector_length_vf4_i32(i32 zeroext %tc) {
117 ; CHECK-LABEL: vector_length_vf4_i32:
119 ; CHECK-NEXT: vsetvli a0, a0, e8, mf2, ta, ma
121 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 4, i1 true)
125 define i32 @vector_length_vf4_XLen(iXLen zeroext %tc) {
126 ; CHECK-LABEL: vector_length_vf4_XLen:
128 ; CHECK-NEXT: vsetvli a0, a0, e8, mf2, ta, ma
130 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 4, i1 true)
134 define i32 @vector_length_vf8_i32(i32 zeroext %tc) {
135 ; CHECK-LABEL: vector_length_vf8_i32:
137 ; CHECK-NEXT: vsetvli a0, a0, e8, m1, ta, ma
139 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 8, i1 true)
143 define i32 @vector_length_vf8_XLen(iXLen zeroext %tc) {
144 ; CHECK-LABEL: vector_length_vf8_XLen:
146 ; CHECK-NEXT: vsetvli a0, a0, e8, m1, ta, ma
148 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 8, i1 true)
152 define i32 @vector_length_vf16_i32(i32 zeroext %tc) {
153 ; CHECK-LABEL: vector_length_vf16_i32:
155 ; CHECK-NEXT: vsetvli a0, a0, e8, m2, ta, ma
157 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 16, i1 true)
161 define i32 @vector_length_vf16_XLen(iXLen zeroext %tc) {
162 ; CHECK-LABEL: vector_length_vf16_XLen:
164 ; CHECK-NEXT: vsetvli a0, a0, e8, m2, ta, ma
166 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 16, i1 true)
170 define i32 @vector_length_vf32_i32(i32 zeroext %tc) {
171 ; CHECK-LABEL: vector_length_vf32_i32:
173 ; CHECK-NEXT: vsetvli a0, a0, e8, m4, ta, ma
175 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 32, i1 true)
179 define i32 @vector_length_vf32_XLen(iXLen zeroext %tc) {
180 ; CHECK-LABEL: vector_length_vf32_XLen:
182 ; CHECK-NEXT: vsetvli a0, a0, e8, m4, ta, ma
184 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 32, i1 true)
188 define i32 @vector_length_vf64_i32(i32 zeroext %tc) {
189 ; CHECK-LABEL: vector_length_vf64_i32:
191 ; CHECK-NEXT: vsetvli a0, a0, e8, m8, ta, ma
193 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 64, i1 true)
197 define i32 @vector_length_vf64_XLen(iXLen zeroext %tc) {
198 ; CHECK-LABEL: vector_length_vf64_XLen:
200 ; CHECK-NEXT: vsetvli a0, a0, e8, m8, ta, ma
202 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 64, i1 true)
206 define i32 @vector_length_vf128_i32(i32 zeroext %tc) {
207 ; RV32-LABEL: vector_length_vf128_i32:
209 ; RV32-NEXT: csrr a1, vlenb
210 ; RV32-NEXT: slli a1, a1, 4
211 ; RV32-NEXT: bltu a0, a1, .LBB20_2
212 ; RV32-NEXT: # %bb.1:
213 ; RV32-NEXT: mv a0, a1
214 ; RV32-NEXT: .LBB20_2:
217 ; RV64-LABEL: vector_length_vf128_i32:
219 ; RV64-NEXT: sext.w a0, a0
220 ; RV64-NEXT: csrr a1, vlenb
221 ; RV64-NEXT: slli a1, a1, 4
222 ; RV64-NEXT: bltu a0, a1, .LBB20_2
223 ; RV64-NEXT: # %bb.1:
224 ; RV64-NEXT: mv a0, a1
225 ; RV64-NEXT: .LBB20_2:
227 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 128, i1 true)
231 define i32 @vector_length_vf128_XLen(iXLen zeroext %tc) {
232 ; RV32-LABEL: vector_length_vf128_XLen:
234 ; RV32-NEXT: csrr a1, vlenb
235 ; RV32-NEXT: slli a1, a1, 4
236 ; RV32-NEXT: bltu a0, a1, .LBB21_2
237 ; RV32-NEXT: # %bb.1:
238 ; RV32-NEXT: mv a0, a1
239 ; RV32-NEXT: .LBB21_2:
242 ; RV64-LABEL: vector_length_vf128_XLen:
244 ; RV64-NEXT: sext.w a0, a0
245 ; RV64-NEXT: csrr a1, vlenb
246 ; RV64-NEXT: slli a1, a1, 4
247 ; RV64-NEXT: bltu a0, a1, .LBB21_2
248 ; RV64-NEXT: # %bb.1:
249 ; RV64-NEXT: mv a0, a1
250 ; RV64-NEXT: .LBB21_2:
252 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 128, i1 true)
256 define i32 @vector_length_vf3_i32(i32 zeroext %tc) {
257 ; RV32-LABEL: vector_length_vf3_i32:
259 ; RV32-NEXT: csrr a1, vlenb
260 ; RV32-NEXT: srli a1, a1, 3
261 ; RV32-NEXT: slli a2, a1, 1
262 ; RV32-NEXT: add a1, a2, a1
263 ; RV32-NEXT: bltu a0, a1, .LBB22_2
264 ; RV32-NEXT: # %bb.1:
265 ; RV32-NEXT: mv a0, a1
266 ; RV32-NEXT: .LBB22_2:
269 ; RV64-LABEL: vector_length_vf3_i32:
271 ; RV64-NEXT: sext.w a0, a0
272 ; RV64-NEXT: csrr a1, vlenb
273 ; RV64-NEXT: srli a1, a1, 3
274 ; RV64-NEXT: slli a2, a1, 1
275 ; RV64-NEXT: add a1, a2, a1
276 ; RV64-NEXT: bltu a0, a1, .LBB22_2
277 ; RV64-NEXT: # %bb.1:
278 ; RV64-NEXT: mv a0, a1
279 ; RV64-NEXT: .LBB22_2:
281 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 3, i1 true)
285 define i32 @vector_length_vf3_XLen(iXLen zeroext %tc) {
286 ; RV32-LABEL: vector_length_vf3_XLen:
288 ; RV32-NEXT: csrr a1, vlenb
289 ; RV32-NEXT: srli a1, a1, 3
290 ; RV32-NEXT: slli a2, a1, 1
291 ; RV32-NEXT: add a1, a2, a1
292 ; RV32-NEXT: bltu a0, a1, .LBB23_2
293 ; RV32-NEXT: # %bb.1:
294 ; RV32-NEXT: mv a0, a1
295 ; RV32-NEXT: .LBB23_2:
298 ; RV64-LABEL: vector_length_vf3_XLen:
300 ; RV64-NEXT: sext.w a0, a0
301 ; RV64-NEXT: csrr a1, vlenb
302 ; RV64-NEXT: srli a1, a1, 3
303 ; RV64-NEXT: slli a2, a1, 1
304 ; RV64-NEXT: add a1, a2, a1
305 ; RV64-NEXT: bltu a0, a1, .LBB23_2
306 ; RV64-NEXT: # %bb.1:
307 ; RV64-NEXT: mv a0, a1
308 ; RV64-NEXT: .LBB23_2:
310 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 3, i1 true)