1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=riscv64 -mattr=+v | FileCheck %s
4 declare i64 @llvm.riscv.vsetvlimax(i64, i64);
6 define signext i32 @vsetvlmax_sext() {
7 ; CHECK-LABEL: vsetvlmax_sext:
9 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
11 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 1)
12 %b = trunc i64 %a to i32
16 define zeroext i32 @vsetvlmax_zext() {
17 ; CHECK-LABEL: vsetvlmax_zext:
19 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
21 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 1)
22 %b = trunc i64 %a to i32
26 define i64 @vsetvlmax_e8m1_and14bits() {
27 ; CHECK-LABEL: vsetvlmax_e8m1_and14bits:
29 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
31 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 0)
32 %b = and i64 %a, 16383
36 define i64 @vsetvlmax_e8m1_and13bits() {
37 ; CHECK-LABEL: vsetvlmax_e8m1_and13bits:
39 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
40 ; CHECK-NEXT: slli a0, a0, 51
41 ; CHECK-NEXT: srli a0, a0, 51
43 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 0)
48 define i64 @vsetvlmax_e8m2_and15bits() {
49 ; CHECK-LABEL: vsetvlmax_e8m2_and15bits:
51 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
53 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 1)
54 %b = and i64 %a, 32767
58 define i64 @vsetvlmax_e8m2_and14bits() {
59 ; CHECK-LABEL: vsetvlmax_e8m2_and14bits:
61 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
62 ; CHECK-NEXT: slli a0, a0, 50
63 ; CHECK-NEXT: srli a0, a0, 50
65 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 1)
66 %b = and i64 %a, 16383
70 define i64 @vsetvlmax_e8m4_and16bits() {
71 ; CHECK-LABEL: vsetvlmax_e8m4_and16bits:
73 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
75 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 2)
76 %b = and i64 %a, 65535
80 define i64 @vsetvlmax_e8m4_and15bits() {
81 ; CHECK-LABEL: vsetvlmax_e8m4_and15bits:
83 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
84 ; CHECK-NEXT: slli a0, a0, 49
85 ; CHECK-NEXT: srli a0, a0, 49
87 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 2)
88 %b = and i64 %a, 32767
92 define i64 @vsetvlmax_e8m8_and17bits() {
93 ; CHECK-LABEL: vsetvlmax_e8m8_and17bits:
95 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
97 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 3)
98 %b = and i64 %a, 131071
102 define i64 @vsetvlmax_e8m8_and16bits() {
103 ; CHECK-LABEL: vsetvlmax_e8m8_and16bits:
105 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
106 ; CHECK-NEXT: slli a0, a0, 48
107 ; CHECK-NEXT: srli a0, a0, 48
109 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 3)
110 %b = and i64 %a, 65535
114 define i64 @vsetvlmax_e8mf2_and11bits() {
115 ; CHECK-LABEL: vsetvlmax_e8mf2_and11bits:
117 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
119 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 5)
120 %b = and i64 %a, 2047
124 define i64 @vsetvlmax_e8mf2_and10bits() {
125 ; CHECK-LABEL: vsetvlmax_e8mf2_and10bits:
127 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
128 ; CHECK-NEXT: andi a0, a0, 1023
130 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 5)
131 %b = and i64 %a, 1023
135 define i64 @vsetvlmax_e8mf4_and12bits() {
136 ; CHECK-LABEL: vsetvlmax_e8mf4_and12bits:
138 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
140 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 6)
141 %b = and i64 %a, 4095
145 define i64 @vsetvlmax_e8mf4_and11bits() {
146 ; CHECK-LABEL: vsetvlmax_e8mf4_and11bits:
148 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
149 ; CHECK-NEXT: andi a0, a0, 2047
151 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 6)
152 %b = and i64 %a, 2047
156 define i64 @vsetvlmax_e8mf8_and13bits() {
157 ; CHECK-LABEL: vsetvlmax_e8mf8_and13bits:
159 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
161 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 7)
162 %b = and i64 %a, 8191
166 define i64 @vsetvlmax_e8mf8_and12bits() {
167 ; CHECK-LABEL: vsetvlmax_e8mf8_and12bits:
169 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
170 ; CHECK-NEXT: slli a0, a0, 52
171 ; CHECK-NEXT: srli a0, a0, 52
173 %a = call i64 @llvm.riscv.vsetvlimax(i64 0, i64 7)
174 %b = and i64 %a, 4095
178 define i64 @vsetvlmax_e16m1_and13bits() {
179 ; CHECK-LABEL: vsetvlmax_e16m1_and13bits:
181 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
183 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 0)
184 %b = and i64 %a, 8191
188 define i64 @vsetvlmax_e16m1_and12bits() {
189 ; CHECK-LABEL: vsetvlmax_e16m1_and12bits:
191 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
192 ; CHECK-NEXT: slli a0, a0, 52
193 ; CHECK-NEXT: srli a0, a0, 52
195 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 0)
196 %b = and i64 %a, 4095
200 define i64 @vsetvlmax_e16m2_and14bits() {
201 ; CHECK-LABEL: vsetvlmax_e16m2_and14bits:
203 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
205 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 1)
206 %b = and i64 %a, 16383
210 define i64 @vsetvlmax_e16m2_and13bits() {
211 ; CHECK-LABEL: vsetvlmax_e16m2_and13bits:
213 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
214 ; CHECK-NEXT: slli a0, a0, 51
215 ; CHECK-NEXT: srli a0, a0, 51
217 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 1)
218 %b = and i64 %a, 8191
222 define i64 @vsetvlmax_e16m4_and15bits() {
223 ; CHECK-LABEL: vsetvlmax_e16m4_and15bits:
225 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
227 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 2)
228 %b = and i64 %a, 32767
232 define i64 @vsetvlmax_e16m4_and14bits() {
233 ; CHECK-LABEL: vsetvlmax_e16m4_and14bits:
235 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
236 ; CHECK-NEXT: slli a0, a0, 50
237 ; CHECK-NEXT: srli a0, a0, 50
239 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 2)
240 %b = and i64 %a, 16383
244 define i64 @vsetvlmax_e16m8_and16bits() {
245 ; CHECK-LABEL: vsetvlmax_e16m8_and16bits:
247 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
249 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 3)
250 %b = and i64 %a, 65535
254 define i64 @vsetvlmax_e16m8_and15bits() {
255 ; CHECK-LABEL: vsetvlmax_e16m8_and15bits:
257 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
258 ; CHECK-NEXT: slli a0, a0, 49
259 ; CHECK-NEXT: srli a0, a0, 49
261 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 3)
262 %b = and i64 %a, 32767
266 define i64 @vsetvlmax_e16mf2_and10bits() {
267 ; CHECK-LABEL: vsetvlmax_e16mf2_and10bits:
269 ; CHECK-NEXT: vsetvli a0, zero, e16, mf8, ta, ma
271 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 5)
272 %b = and i64 %a, 1023
276 define i64 @vsetvlmax_e16mf2_and9bits() {
277 ; CHECK-LABEL: vsetvlmax_e16mf2_and9bits:
279 ; CHECK-NEXT: vsetvli a0, zero, e16, mf8, ta, ma
280 ; CHECK-NEXT: andi a0, a0, 511
282 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 5)
287 define i64 @vsetvlmax_e16mf4_and11bits() {
288 ; CHECK-LABEL: vsetvlmax_e16mf4_and11bits:
290 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
292 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 6)
293 %b = and i64 %a, 2047
297 define i64 @vsetvlmax_e16mf4_and10bits() {
298 ; CHECK-LABEL: vsetvlmax_e16mf4_and10bits:
300 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
301 ; CHECK-NEXT: andi a0, a0, 1023
303 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 6)
304 %b = and i64 %a, 1023
308 define i64 @vsetvlmax_e16mf8_and12bits() {
309 ; CHECK-LABEL: vsetvlmax_e16mf8_and12bits:
311 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
313 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 7)
314 %b = and i64 %a, 4095
318 define i64 @vsetvlmax_e16mf8_and11bits() {
319 ; CHECK-LABEL: vsetvlmax_e16mf8_and11bits:
321 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
322 ; CHECK-NEXT: andi a0, a0, 2047
324 %a = call i64 @llvm.riscv.vsetvlimax(i64 1, i64 7)
325 %b = and i64 %a, 2047
329 define i64 @vsetvlmax_e32m1_and12bits() {
330 ; CHECK-LABEL: vsetvlmax_e32m1_and12bits:
332 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
334 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 0)
335 %b = and i64 %a, 4095
339 define i64 @vsetvlmax_e32m1_and11bits() {
340 ; CHECK-LABEL: vsetvlmax_e32m1_and11bits:
342 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
343 ; CHECK-NEXT: andi a0, a0, 2047
345 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 0)
346 %b = and i64 %a, 2047
350 define i64 @vsetvlmax_e32m2_and13bits() {
351 ; CHECK-LABEL: vsetvlmax_e32m2_and13bits:
353 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
355 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 1)
356 %b = and i64 %a, 8191
360 define i64 @vsetvlmax_e32m2_and12bits() {
361 ; CHECK-LABEL: vsetvlmax_e32m2_and12bits:
363 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
364 ; CHECK-NEXT: slli a0, a0, 52
365 ; CHECK-NEXT: srli a0, a0, 52
367 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 1)
368 %b = and i64 %a, 4095
372 define i64 @vsetvlmax_e32m4_and14bits() {
373 ; CHECK-LABEL: vsetvlmax_e32m4_and14bits:
375 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
377 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 2)
378 %b = and i64 %a, 16383
382 define i64 @vsetvlmax_e32m4_and13bits() {
383 ; CHECK-LABEL: vsetvlmax_e32m4_and13bits:
385 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
386 ; CHECK-NEXT: slli a0, a0, 51
387 ; CHECK-NEXT: srli a0, a0, 51
389 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 2)
390 %b = and i64 %a, 8191
394 define i64 @vsetvlmax_e32m8_and15bits() {
395 ; CHECK-LABEL: vsetvlmax_e32m8_and15bits:
397 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
399 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 3)
400 %b = and i64 %a, 32767
404 define i64 @vsetvlmax_e32m8_and14bits() {
405 ; CHECK-LABEL: vsetvlmax_e32m8_and14bits:
407 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
408 ; CHECK-NEXT: slli a0, a0, 50
409 ; CHECK-NEXT: srli a0, a0, 50
411 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 3)
412 %b = and i64 %a, 16383
416 define i64 @vsetvlmax_e32mf2_and9bits() {
417 ; CHECK-LABEL: vsetvlmax_e32mf2_and9bits:
419 ; CHECK-NEXT: vsetvli a0, zero, e32, mf8, ta, ma
421 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 5)
426 define i64 @vsetvlmax_e32mf2_and8bits() {
427 ; CHECK-LABEL: vsetvlmax_e32mf2_and8bits:
429 ; CHECK-NEXT: vsetvli a0, zero, e32, mf8, ta, ma
430 ; CHECK-NEXT: andi a0, a0, 255
432 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 5)
437 define i64 @vsetvlmax_e32mf4_and10bits() {
438 ; CHECK-LABEL: vsetvlmax_e32mf4_and10bits:
440 ; CHECK-NEXT: vsetvli a0, zero, e32, mf4, ta, ma
442 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 6)
443 %b = and i64 %a, 1023
447 define i64 @vsetvlmax_e32mf4_and9bits() {
448 ; CHECK-LABEL: vsetvlmax_e32mf4_and9bits:
450 ; CHECK-NEXT: vsetvli a0, zero, e32, mf4, ta, ma
451 ; CHECK-NEXT: andi a0, a0, 511
453 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 6)
458 define i64 @vsetvlmax_e32mf8_and11bits() {
459 ; CHECK-LABEL: vsetvlmax_e32mf8_and11bits:
461 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
463 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 7)
464 %b = and i64 %a, 2047
468 define i64 @vsetvlmax_e32mf8_and10bits() {
469 ; CHECK-LABEL: vsetvlmax_e32mf8_and10bits:
471 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
472 ; CHECK-NEXT: andi a0, a0, 1023
474 %a = call i64 @llvm.riscv.vsetvlimax(i64 2, i64 7)
475 %b = and i64 %a, 1023
479 define i64 @vsetvlmax_e64m1_and11bits() {
480 ; CHECK-LABEL: vsetvlmax_e64m1_and11bits:
482 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
484 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 0)
485 %b = and i64 %a, 2047
489 define i64 @vsetvlmax_e64m1_and10bits() {
490 ; CHECK-LABEL: vsetvlmax_e64m1_and10bits:
492 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
493 ; CHECK-NEXT: andi a0, a0, 1023
495 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 0)
496 %b = and i64 %a, 1023
500 define i64 @vsetvlmax_e64m2_and12bits() {
501 ; CHECK-LABEL: vsetvlmax_e64m2_and12bits:
503 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
505 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 1)
506 %b = and i64 %a, 4095
510 define i64 @vsetvlmax_e64m2_and11bits() {
511 ; CHECK-LABEL: vsetvlmax_e64m2_and11bits:
513 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
514 ; CHECK-NEXT: andi a0, a0, 2047
516 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 1)
517 %b = and i64 %a, 2047
521 define i64 @vsetvlmax_e64m4_and13bits() {
522 ; CHECK-LABEL: vsetvlmax_e64m4_and13bits:
524 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
526 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 2)
527 %b = and i64 %a, 8191
531 define i64 @vsetvlmax_e64m4_and12bits() {
532 ; CHECK-LABEL: vsetvlmax_e64m4_and12bits:
534 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
535 ; CHECK-NEXT: slli a0, a0, 52
536 ; CHECK-NEXT: srli a0, a0, 52
538 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 2)
539 %b = and i64 %a, 4095
543 define i64 @vsetvlmax_e64m8_and14bits() {
544 ; CHECK-LABEL: vsetvlmax_e64m8_and14bits:
546 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
548 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 3)
549 %b = and i64 %a, 16383
553 define i64 @vsetvlmax_e64m8_and13bits() {
554 ; CHECK-LABEL: vsetvlmax_e64m8_and13bits:
556 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
557 ; CHECK-NEXT: slli a0, a0, 51
558 ; CHECK-NEXT: srli a0, a0, 51
560 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 3)
561 %b = and i64 %a, 8191
565 define i64 @vsetvlmax_e64mf2_and8bits() {
566 ; CHECK-LABEL: vsetvlmax_e64mf2_and8bits:
568 ; CHECK-NEXT: vsetvli a0, zero, e64, mf8, ta, ma
570 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 5)
575 define i64 @vsetvlmax_e64mf2_and7bits() {
576 ; CHECK-LABEL: vsetvlmax_e64mf2_and7bits:
578 ; CHECK-NEXT: vsetvli a0, zero, e64, mf8, ta, ma
579 ; CHECK-NEXT: andi a0, a0, 127
581 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 5)
586 define i64 @vsetvlmax_e64mf4_and9bits() {
587 ; CHECK-LABEL: vsetvlmax_e64mf4_and9bits:
589 ; CHECK-NEXT: vsetvli a0, zero, e64, mf4, ta, ma
591 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 6)
596 define i64 @vsetvlmax_e64mf4_and8bits() {
597 ; CHECK-LABEL: vsetvlmax_e64mf4_and8bits:
599 ; CHECK-NEXT: vsetvli a0, zero, e64, mf4, ta, ma
600 ; CHECK-NEXT: andi a0, a0, 255
602 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 6)
607 define i64 @vsetvlmax_e64mf8_and10bits() {
608 ; CHECK-LABEL: vsetvlmax_e64mf8_and10bits:
610 ; CHECK-NEXT: vsetvli a0, zero, e64, mf2, ta, ma
612 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 7)
613 %b = and i64 %a, 1023
617 define i64 @vsetvlmax_e64mf8_and9bits() {
618 ; CHECK-LABEL: vsetvlmax_e64mf8_and9bits:
620 ; CHECK-NEXT: vsetvli a0, zero, e64, mf2, ta, ma
621 ; CHECK-NEXT: andi a0, a0, 511
623 %a = call i64 @llvm.riscv.vsetvlimax(i64 3, i64 7)