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 ; RV32-LABEL: vector_length_i32_fixed:
58 ; RV32-NEXT: bltu a0, a1, .LBB4_2
64 ; RV64-LABEL: vector_length_i32_fixed:
66 ; RV64-NEXT: sext.w a0, a0
68 ; RV64-NEXT: bltu a0, a1, .LBB4_2
73 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 2, i1 false)
77 define i32 @vector_length_XLen_fixed(iXLen zeroext %tc) {
78 ; RV32-LABEL: vector_length_XLen_fixed:
81 ; RV32-NEXT: bltu a0, a1, .LBB5_2
87 ; RV64-LABEL: vector_length_XLen_fixed:
89 ; RV64-NEXT: sext.w a0, a0
91 ; RV64-NEXT: bltu a0, a1, .LBB5_2
96 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 2, i1 false)
100 define i32 @vector_length_vf1_i32(i32 zeroext %tc) {
101 ; CHECK-LABEL: vector_length_vf1_i32:
103 ; CHECK-NEXT: vsetvli a0, a0, e8, mf8, ta, ma
105 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 1, i1 true)
109 define i32 @vector_length_vf1_XLen(iXLen zeroext %tc) {
110 ; CHECK-LABEL: vector_length_vf1_XLen:
112 ; CHECK-NEXT: vsetvli a0, a0, e8, mf8, ta, ma
114 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 1, i1 true)
118 define i32 @vector_length_vf2_i32(i32 zeroext %tc) {
119 ; CHECK-LABEL: vector_length_vf2_i32:
121 ; CHECK-NEXT: vsetvli a0, a0, e8, mf4, ta, ma
123 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 2, i1 true)
127 define i32 @vector_length_vf2_XLen(iXLen zeroext %tc) {
128 ; CHECK-LABEL: vector_length_vf2_XLen:
130 ; CHECK-NEXT: vsetvli a0, a0, e8, mf4, ta, ma
132 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 2, i1 true)
136 define i32 @vector_length_vf4_i32(i32 zeroext %tc) {
137 ; CHECK-LABEL: vector_length_vf4_i32:
139 ; CHECK-NEXT: vsetvli a0, a0, e8, mf2, ta, ma
141 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 4, i1 true)
145 define i32 @vector_length_vf4_XLen(iXLen zeroext %tc) {
146 ; CHECK-LABEL: vector_length_vf4_XLen:
148 ; CHECK-NEXT: vsetvli a0, a0, e8, mf2, ta, ma
150 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 4, i1 true)
154 define i32 @vector_length_vf8_i32(i32 zeroext %tc) {
155 ; CHECK-LABEL: vector_length_vf8_i32:
157 ; CHECK-NEXT: vsetvli a0, a0, e8, m1, ta, ma
159 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 8, i1 true)
163 define i32 @vector_length_vf8_XLen(iXLen zeroext %tc) {
164 ; CHECK-LABEL: vector_length_vf8_XLen:
166 ; CHECK-NEXT: vsetvli a0, a0, e8, m1, ta, ma
168 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 8, i1 true)
172 define i32 @vector_length_vf16_i32(i32 zeroext %tc) {
173 ; CHECK-LABEL: vector_length_vf16_i32:
175 ; CHECK-NEXT: vsetvli a0, a0, e8, m2, ta, ma
177 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 16, i1 true)
181 define i32 @vector_length_vf16_XLen(iXLen zeroext %tc) {
182 ; CHECK-LABEL: vector_length_vf16_XLen:
184 ; CHECK-NEXT: vsetvli a0, a0, e8, m2, ta, ma
186 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 16, i1 true)
190 define i32 @vector_length_vf32_i32(i32 zeroext %tc) {
191 ; CHECK-LABEL: vector_length_vf32_i32:
193 ; CHECK-NEXT: vsetvli a0, a0, e8, m4, ta, ma
195 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 32, i1 true)
199 define i32 @vector_length_vf32_XLen(iXLen zeroext %tc) {
200 ; CHECK-LABEL: vector_length_vf32_XLen:
202 ; CHECK-NEXT: vsetvli a0, a0, e8, m4, ta, ma
204 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 32, i1 true)
208 define i32 @vector_length_vf64_i32(i32 zeroext %tc) {
209 ; CHECK-LABEL: vector_length_vf64_i32:
211 ; CHECK-NEXT: vsetvli a0, a0, e8, m8, ta, ma
213 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 64, i1 true)
217 define i32 @vector_length_vf64_XLen(iXLen zeroext %tc) {
218 ; CHECK-LABEL: vector_length_vf64_XLen:
220 ; CHECK-NEXT: vsetvli a0, a0, e8, m8, ta, ma
222 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 64, i1 true)
226 define i32 @vector_length_vf128_i32(i32 zeroext %tc) {
227 ; RV32-LABEL: vector_length_vf128_i32:
229 ; RV32-NEXT: csrr a1, vlenb
230 ; RV32-NEXT: slli a1, a1, 4
231 ; RV32-NEXT: bltu a0, a1, .LBB20_2
232 ; RV32-NEXT: # %bb.1:
233 ; RV32-NEXT: mv a0, a1
234 ; RV32-NEXT: .LBB20_2:
237 ; RV64-LABEL: vector_length_vf128_i32:
239 ; RV64-NEXT: sext.w a0, a0
240 ; RV64-NEXT: csrr a1, vlenb
241 ; RV64-NEXT: slli a1, a1, 4
242 ; RV64-NEXT: bltu a0, a1, .LBB20_2
243 ; RV64-NEXT: # %bb.1:
244 ; RV64-NEXT: mv a0, a1
245 ; RV64-NEXT: .LBB20_2:
247 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 128, i1 true)
251 define i32 @vector_length_vf128_XLen(iXLen zeroext %tc) {
252 ; RV32-LABEL: vector_length_vf128_XLen:
254 ; RV32-NEXT: csrr a1, vlenb
255 ; RV32-NEXT: slli a1, a1, 4
256 ; RV32-NEXT: bltu a0, a1, .LBB21_2
257 ; RV32-NEXT: # %bb.1:
258 ; RV32-NEXT: mv a0, a1
259 ; RV32-NEXT: .LBB21_2:
262 ; RV64-LABEL: vector_length_vf128_XLen:
264 ; RV64-NEXT: sext.w a0, a0
265 ; RV64-NEXT: csrr a1, vlenb
266 ; RV64-NEXT: slli a1, a1, 4
267 ; RV64-NEXT: bltu a0, a1, .LBB21_2
268 ; RV64-NEXT: # %bb.1:
269 ; RV64-NEXT: mv a0, a1
270 ; RV64-NEXT: .LBB21_2:
272 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 128, i1 true)
276 define i32 @vector_length_vf3_i32(i32 zeroext %tc) {
277 ; RV32-LABEL: vector_length_vf3_i32:
279 ; RV32-NEXT: csrr a1, vlenb
280 ; RV32-NEXT: srli a1, a1, 3
281 ; RV32-NEXT: slli a2, a1, 1
282 ; RV32-NEXT: add a1, a2, a1
283 ; RV32-NEXT: bltu a0, a1, .LBB22_2
284 ; RV32-NEXT: # %bb.1:
285 ; RV32-NEXT: mv a0, a1
286 ; RV32-NEXT: .LBB22_2:
289 ; RV64-LABEL: vector_length_vf3_i32:
291 ; RV64-NEXT: sext.w a0, a0
292 ; RV64-NEXT: csrr a1, vlenb
293 ; RV64-NEXT: srli a1, a1, 3
294 ; RV64-NEXT: slli a2, a1, 1
295 ; RV64-NEXT: add a1, a2, a1
296 ; RV64-NEXT: bltu a0, a1, .LBB22_2
297 ; RV64-NEXT: # %bb.1:
298 ; RV64-NEXT: mv a0, a1
299 ; RV64-NEXT: .LBB22_2:
301 %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 3, i1 true)
305 define i32 @vector_length_vf3_XLen(iXLen zeroext %tc) {
306 ; RV32-LABEL: vector_length_vf3_XLen:
308 ; RV32-NEXT: csrr a1, vlenb
309 ; RV32-NEXT: srli a1, a1, 3
310 ; RV32-NEXT: slli a2, a1, 1
311 ; RV32-NEXT: add a1, a2, a1
312 ; RV32-NEXT: bltu a0, a1, .LBB23_2
313 ; RV32-NEXT: # %bb.1:
314 ; RV32-NEXT: mv a0, a1
315 ; RV32-NEXT: .LBB23_2:
318 ; RV64-LABEL: vector_length_vf3_XLen:
320 ; RV64-NEXT: sext.w a0, a0
321 ; RV64-NEXT: csrr a1, vlenb
322 ; RV64-NEXT: srli a1, a1, 3
323 ; RV64-NEXT: slli a2, a1, 1
324 ; RV64-NEXT: add a1, a2, a1
325 ; RV64-NEXT: bltu a0, a1, .LBB23_2
326 ; RV64-NEXT: # %bb.1:
327 ; RV64-NEXT: mv a0, a1
328 ; RV64-NEXT: .LBB23_2:
330 %a = call i32 @llvm.experimental.get.vector.length.iXLen(iXLen %tc, i32 3, i1 true)