1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefixes=CHECK,RV64I
4 ; RUN: llc -mtriple=riscv64 -mattr=+zbs -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefixes=CHECK,RV64ZBS
7 define signext i32 @bclr_i32(i32 signext %a, i32 signext %b) nounwind {
8 ; RV64I-LABEL: bclr_i32:
10 ; RV64I-NEXT: li a2, 1
11 ; RV64I-NEXT: sllw a1, a2, a1
12 ; RV64I-NEXT: not a1, a1
13 ; RV64I-NEXT: and a0, a1, a0
16 ; RV64ZBS-LABEL: bclr_i32:
18 ; RV64ZBS-NEXT: andi a1, a1, 31
19 ; RV64ZBS-NEXT: bclr a0, a0, a1
20 ; RV64ZBS-NEXT: sext.w a0, a0
23 %shl = shl nuw i32 1, %and
24 %neg = xor i32 %shl, -1
25 %and1 = and i32 %neg, %a
29 define signext i32 @bclr_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
30 ; RV64I-LABEL: bclr_i32_no_mask:
32 ; RV64I-NEXT: li a2, 1
33 ; RV64I-NEXT: sllw a1, a2, a1
34 ; RV64I-NEXT: not a1, a1
35 ; RV64I-NEXT: and a0, a1, a0
38 ; RV64ZBS-LABEL: bclr_i32_no_mask:
40 ; RV64ZBS-NEXT: bclr a0, a0, a1
41 ; RV64ZBS-NEXT: sext.w a0, a0
44 %neg = xor i32 %shl, -1
45 %and1 = and i32 %neg, %a
49 define signext i32 @bclr_i32_load(ptr %p, i32 signext %b) nounwind {
50 ; RV64I-LABEL: bclr_i32_load:
52 ; RV64I-NEXT: lw a0, 0(a0)
53 ; RV64I-NEXT: li a2, 1
54 ; RV64I-NEXT: sllw a1, a2, a1
55 ; RV64I-NEXT: not a1, a1
56 ; RV64I-NEXT: and a0, a1, a0
59 ; RV64ZBS-LABEL: bclr_i32_load:
61 ; RV64ZBS-NEXT: lw a0, 0(a0)
62 ; RV64ZBS-NEXT: bclr a0, a0, a1
63 ; RV64ZBS-NEXT: sext.w a0, a0
67 %neg = xor i32 %shl, -1
68 %and1 = and i32 %neg, %a
72 define i64 @bclr_i64(i64 %a, i64 %b) nounwind {
73 ; RV64I-LABEL: bclr_i64:
75 ; RV64I-NEXT: li a2, 1
76 ; RV64I-NEXT: sll a1, a2, a1
77 ; RV64I-NEXT: not a1, a1
78 ; RV64I-NEXT: and a0, a1, a0
81 ; RV64ZBS-LABEL: bclr_i64:
83 ; RV64ZBS-NEXT: bclr a0, a0, a1
86 %shl = shl nuw i64 1, %and
87 %neg = xor i64 %shl, -1
88 %and1 = and i64 %neg, %a
92 define i64 @bclr_i64_no_mask(i64 %a, i64 %b) nounwind {
93 ; RV64I-LABEL: bclr_i64_no_mask:
95 ; RV64I-NEXT: li a2, 1
96 ; RV64I-NEXT: sll a1, a2, a1
97 ; RV64I-NEXT: not a1, a1
98 ; RV64I-NEXT: and a0, a1, a0
101 ; RV64ZBS-LABEL: bclr_i64_no_mask:
103 ; RV64ZBS-NEXT: bclr a0, a0, a1
106 %neg = xor i64 %shl, -1
107 %and1 = and i64 %neg, %a
111 define signext i32 @bset_i32(i32 signext %a, i32 signext %b) nounwind {
112 ; RV64I-LABEL: bset_i32:
114 ; RV64I-NEXT: li a2, 1
115 ; RV64I-NEXT: sllw a1, a2, a1
116 ; RV64I-NEXT: or a0, a1, a0
119 ; RV64ZBS-LABEL: bset_i32:
121 ; RV64ZBS-NEXT: andi a1, a1, 31
122 ; RV64ZBS-NEXT: bset a0, a0, a1
123 ; RV64ZBS-NEXT: sext.w a0, a0
125 %and = and i32 %b, 31
126 %shl = shl nuw i32 1, %and
127 %or = or i32 %shl, %a
131 define signext i32 @bset_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
132 ; RV64I-LABEL: bset_i32_no_mask:
134 ; RV64I-NEXT: li a2, 1
135 ; RV64I-NEXT: sllw a1, a2, a1
136 ; RV64I-NEXT: or a0, a1, a0
139 ; RV64ZBS-LABEL: bset_i32_no_mask:
141 ; RV64ZBS-NEXT: bset a0, a0, a1
142 ; RV64ZBS-NEXT: sext.w a0, a0
145 %or = or i32 %shl, %a
149 define signext i32 @bset_i32_load(ptr %p, i32 signext %b) nounwind {
150 ; RV64I-LABEL: bset_i32_load:
152 ; RV64I-NEXT: lw a0, 0(a0)
153 ; RV64I-NEXT: li a2, 1
154 ; RV64I-NEXT: sllw a1, a2, a1
155 ; RV64I-NEXT: or a0, a1, a0
158 ; RV64ZBS-LABEL: bset_i32_load:
160 ; RV64ZBS-NEXT: lw a0, 0(a0)
161 ; RV64ZBS-NEXT: bset a0, a0, a1
162 ; RV64ZBS-NEXT: sext.w a0, a0
164 %a = load i32, ptr %p
166 %or = or i32 %shl, %a
170 ; We can use bsetw for 1 << x by setting the first source to zero.
171 define signext i32 @bset_i32_zero(i32 signext %a) nounwind {
172 ; RV64I-LABEL: bset_i32_zero:
174 ; RV64I-NEXT: li a1, 1
175 ; RV64I-NEXT: sllw a0, a1, a0
178 ; RV64ZBS-LABEL: bset_i32_zero:
180 ; RV64ZBS-NEXT: bset a0, zero, a0
181 ; RV64ZBS-NEXT: sext.w a0, a0
187 define i64 @bset_i64(i64 %a, i64 %b) nounwind {
188 ; RV64I-LABEL: bset_i64:
190 ; RV64I-NEXT: li a2, 1
191 ; RV64I-NEXT: sll a1, a2, a1
192 ; RV64I-NEXT: or a0, a1, a0
195 ; RV64ZBS-LABEL: bset_i64:
197 ; RV64ZBS-NEXT: bset a0, a0, a1
199 %conv = and i64 %b, 63
200 %shl = shl nuw i64 1, %conv
201 %or = or i64 %shl, %a
205 define i64 @bset_i64_no_mask(i64 %a, i64 %b) nounwind {
206 ; RV64I-LABEL: bset_i64_no_mask:
208 ; RV64I-NEXT: li a2, 1
209 ; RV64I-NEXT: sll a1, a2, a1
210 ; RV64I-NEXT: or a0, a1, a0
213 ; RV64ZBS-LABEL: bset_i64_no_mask:
215 ; RV64ZBS-NEXT: bset a0, a0, a1
218 %or = or i64 %shl, %a
222 ; We can use bsetw for 1 << x by setting the first source to zero.
223 define signext i64 @bset_i64_zero(i64 signext %a) nounwind {
224 ; RV64I-LABEL: bset_i64_zero:
226 ; RV64I-NEXT: li a1, 1
227 ; RV64I-NEXT: sll a0, a1, a0
230 ; RV64ZBS-LABEL: bset_i64_zero:
232 ; RV64ZBS-NEXT: bset a0, zero, a0
238 define signext i32 @binv_i32(i32 signext %a, i32 signext %b) nounwind {
239 ; RV64I-LABEL: binv_i32:
241 ; RV64I-NEXT: li a2, 1
242 ; RV64I-NEXT: sllw a1, a2, a1
243 ; RV64I-NEXT: xor a0, a1, a0
246 ; RV64ZBS-LABEL: binv_i32:
248 ; RV64ZBS-NEXT: andi a1, a1, 31
249 ; RV64ZBS-NEXT: binv a0, a0, a1
250 ; RV64ZBS-NEXT: sext.w a0, a0
252 %and = and i32 %b, 31
253 %shl = shl nuw i32 1, %and
254 %xor = xor i32 %shl, %a
258 define signext i32 @binv_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
259 ; RV64I-LABEL: binv_i32_no_mask:
261 ; RV64I-NEXT: li a2, 1
262 ; RV64I-NEXT: sllw a1, a2, a1
263 ; RV64I-NEXT: xor a0, a1, a0
266 ; RV64ZBS-LABEL: binv_i32_no_mask:
268 ; RV64ZBS-NEXT: binv a0, a0, a1
269 ; RV64ZBS-NEXT: sext.w a0, a0
272 %xor = xor i32 %shl, %a
276 define signext i32 @binv_i32_load(ptr %p, i32 signext %b) nounwind {
277 ; RV64I-LABEL: binv_i32_load:
279 ; RV64I-NEXT: lw a0, 0(a0)
280 ; RV64I-NEXT: li a2, 1
281 ; RV64I-NEXT: sllw a1, a2, a1
282 ; RV64I-NEXT: xor a0, a1, a0
285 ; RV64ZBS-LABEL: binv_i32_load:
287 ; RV64ZBS-NEXT: lw a0, 0(a0)
288 ; RV64ZBS-NEXT: binv a0, a0, a1
289 ; RV64ZBS-NEXT: sext.w a0, a0
291 %a = load i32, ptr %p
293 %xor = xor i32 %shl, %a
297 define i64 @binv_i64(i64 %a, i64 %b) nounwind {
298 ; RV64I-LABEL: binv_i64:
300 ; RV64I-NEXT: li a2, 1
301 ; RV64I-NEXT: sll a1, a2, a1
302 ; RV64I-NEXT: xor a0, a1, a0
305 ; RV64ZBS-LABEL: binv_i64:
307 ; RV64ZBS-NEXT: binv a0, a0, a1
309 %conv = and i64 %b, 63
310 %shl = shl nuw i64 1, %conv
311 %xor = xor i64 %shl, %a
315 define i64 @binv_i64_no_mask(i64 %a, i64 %b) nounwind {
316 ; RV64I-LABEL: binv_i64_no_mask:
318 ; RV64I-NEXT: li a2, 1
319 ; RV64I-NEXT: sll a1, a2, a1
320 ; RV64I-NEXT: xor a0, a1, a0
323 ; RV64ZBS-LABEL: binv_i64_no_mask:
325 ; RV64ZBS-NEXT: binv a0, a0, a1
327 %shl = shl nuw i64 1, %b
328 %xor = xor i64 %shl, %a
332 define signext i32 @bext_i32(i32 signext %a, i32 signext %b) nounwind {
333 ; RV64I-LABEL: bext_i32:
335 ; RV64I-NEXT: srlw a0, a0, a1
336 ; RV64I-NEXT: andi a0, a0, 1
339 ; RV64ZBS-LABEL: bext_i32:
341 ; RV64ZBS-NEXT: andi a1, a1, 31
342 ; RV64ZBS-NEXT: bext a0, a0, a1
344 %and = and i32 %b, 31
345 %shr = lshr i32 %a, %and
346 %and1 = and i32 %shr, 1
350 define signext i32 @bext_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
351 ; RV64I-LABEL: bext_i32_no_mask:
353 ; RV64I-NEXT: srlw a0, a0, a1
354 ; RV64I-NEXT: andi a0, a0, 1
357 ; RV64ZBS-LABEL: bext_i32_no_mask:
359 ; RV64ZBS-NEXT: bext a0, a0, a1
361 %shr = lshr i32 %a, %b
362 %and1 = and i32 %shr, 1
366 ; This gets previous converted to (i1 (truncate (srl X, Y)). Make sure we are
368 define void @bext_i32_trunc(i32 signext %0, i32 signext %1) {
369 ; RV64I-LABEL: bext_i32_trunc:
371 ; RV64I-NEXT: srlw a0, a0, a1
372 ; RV64I-NEXT: andi a0, a0, 1
373 ; RV64I-NEXT: beqz a0, .LBB19_2
374 ; RV64I-NEXT: # %bb.1:
376 ; RV64I-NEXT: .LBB19_2:
377 ; RV64I-NEXT: tail bar@plt
379 ; RV64ZBS-LABEL: bext_i32_trunc:
381 ; RV64ZBS-NEXT: bext a0, a0, a1
382 ; RV64ZBS-NEXT: beqz a0, .LBB19_2
383 ; RV64ZBS-NEXT: # %bb.1:
385 ; RV64ZBS-NEXT: .LBB19_2:
386 ; RV64ZBS-NEXT: tail bar@plt
389 %5 = icmp eq i32 %4, 0
390 br i1 %5, label %6, label %7
393 tail call void @bar()
402 define i64 @bext_i64(i64 %a, i64 %b) nounwind {
403 ; RV64I-LABEL: bext_i64:
405 ; RV64I-NEXT: srl a0, a0, a1
406 ; RV64I-NEXT: andi a0, a0, 1
409 ; RV64ZBS-LABEL: bext_i64:
411 ; RV64ZBS-NEXT: bext a0, a0, a1
413 %conv = and i64 %b, 63
414 %shr = lshr i64 %a, %conv
415 %and1 = and i64 %shr, 1
419 define i64 @bext_i64_no_mask(i64 %a, i64 %b) nounwind {
420 ; RV64I-LABEL: bext_i64_no_mask:
422 ; RV64I-NEXT: srl a0, a0, a1
423 ; RV64I-NEXT: andi a0, a0, 1
426 ; RV64ZBS-LABEL: bext_i64_no_mask:
428 ; RV64ZBS-NEXT: bext a0, a0, a1
430 %shr = lshr i64 %a, %b
431 %and1 = and i64 %shr, 1
435 define signext i32 @bexti_i32(i32 signext %a) nounwind {
436 ; RV64I-LABEL: bexti_i32:
438 ; RV64I-NEXT: slli a0, a0, 58
439 ; RV64I-NEXT: srli a0, a0, 63
442 ; RV64ZBS-LABEL: bexti_i32:
444 ; RV64ZBS-NEXT: bexti a0, a0, 5
446 %shr = lshr i32 %a, 5
447 %and = and i32 %shr, 1
451 define i64 @bexti_i64(i64 %a) nounwind {
452 ; RV64I-LABEL: bexti_i64:
454 ; RV64I-NEXT: slli a0, a0, 58
455 ; RV64I-NEXT: srli a0, a0, 63
458 ; RV64ZBS-LABEL: bexti_i64:
460 ; RV64ZBS-NEXT: bexti a0, a0, 5
462 %shr = lshr i64 %a, 5
463 %and = and i64 %shr, 1
467 define signext i32 @bexti_i32_cmp(i32 signext %a) nounwind {
468 ; RV64I-LABEL: bexti_i32_cmp:
470 ; RV64I-NEXT: slli a0, a0, 58
471 ; RV64I-NEXT: srli a0, a0, 63
474 ; RV64ZBS-LABEL: bexti_i32_cmp:
476 ; RV64ZBS-NEXT: bexti a0, a0, 5
478 %and = and i32 %a, 32
479 %cmp = icmp ne i32 %and, 0
480 %zext = zext i1 %cmp to i32
484 define i64 @bexti_i64_cmp(i64 %a) nounwind {
485 ; RV64I-LABEL: bexti_i64_cmp:
487 ; RV64I-NEXT: slli a0, a0, 58
488 ; RV64I-NEXT: srli a0, a0, 63
491 ; RV64ZBS-LABEL: bexti_i64_cmp:
493 ; RV64ZBS-NEXT: bexti a0, a0, 5
495 %and = and i64 %a, 32
496 %cmp = icmp ne i64 %and, 0
497 %zext = zext i1 %cmp to i64
501 define signext i32 @bclri_i32_10(i32 signext %a) nounwind {
502 ; CHECK-LABEL: bclri_i32_10:
504 ; CHECK-NEXT: andi a0, a0, -1025
506 %and = and i32 %a, -1025
510 define signext i32 @bclri_i32_11(i32 signext %a) nounwind {
511 ; RV64I-LABEL: bclri_i32_11:
513 ; RV64I-NEXT: lui a1, 1048575
514 ; RV64I-NEXT: addiw a1, a1, 2047
515 ; RV64I-NEXT: and a0, a0, a1
518 ; RV64ZBS-LABEL: bclri_i32_11:
520 ; RV64ZBS-NEXT: bclri a0, a0, 11
522 %and = and i32 %a, -2049
526 define signext i32 @bclri_i32_30(i32 signext %a) nounwind {
527 ; RV64I-LABEL: bclri_i32_30:
529 ; RV64I-NEXT: lui a1, 786432
530 ; RV64I-NEXT: addiw a1, a1, -1
531 ; RV64I-NEXT: and a0, a0, a1
534 ; RV64ZBS-LABEL: bclri_i32_30:
536 ; RV64ZBS-NEXT: bclri a0, a0, 30
538 %and = and i32 %a, -1073741825
542 define signext i32 @bclri_i32_31(i32 signext %a) nounwind {
543 ; CHECK-LABEL: bclri_i32_31:
545 ; CHECK-NEXT: slli a0, a0, 33
546 ; CHECK-NEXT: srli a0, a0, 33
548 %and = and i32 %a, -2147483649
552 define i64 @bclri_i64_10(i64 %a) nounwind {
553 ; CHECK-LABEL: bclri_i64_10:
555 ; CHECK-NEXT: andi a0, a0, -1025
557 %and = and i64 %a, -1025
561 define i64 @bclri_i64_11(i64 %a) nounwind {
562 ; RV64I-LABEL: bclri_i64_11:
564 ; RV64I-NEXT: lui a1, 1048575
565 ; RV64I-NEXT: addiw a1, a1, 2047
566 ; RV64I-NEXT: and a0, a0, a1
569 ; RV64ZBS-LABEL: bclri_i64_11:
571 ; RV64ZBS-NEXT: bclri a0, a0, 11
573 %and = and i64 %a, -2049
577 define i64 @bclri_i64_30(i64 %a) nounwind {
578 ; RV64I-LABEL: bclri_i64_30:
580 ; RV64I-NEXT: lui a1, 786432
581 ; RV64I-NEXT: addiw a1, a1, -1
582 ; RV64I-NEXT: and a0, a0, a1
585 ; RV64ZBS-LABEL: bclri_i64_30:
587 ; RV64ZBS-NEXT: bclri a0, a0, 30
589 %and = and i64 %a, -1073741825
593 define i64 @bclri_i64_31(i64 %a) nounwind {
594 ; RV64I-LABEL: bclri_i64_31:
596 ; RV64I-NEXT: lui a1, 524288
597 ; RV64I-NEXT: addi a1, a1, -1
598 ; RV64I-NEXT: and a0, a0, a1
601 ; RV64ZBS-LABEL: bclri_i64_31:
603 ; RV64ZBS-NEXT: bclri a0, a0, 31
605 %and = and i64 %a, -2147483649
609 define i64 @bclri_i64_62(i64 %a) nounwind {
610 ; RV64I-LABEL: bclri_i64_62:
612 ; RV64I-NEXT: li a1, -1
613 ; RV64I-NEXT: slli a1, a1, 62
614 ; RV64I-NEXT: addi a1, a1, -1
615 ; RV64I-NEXT: and a0, a0, a1
618 ; RV64ZBS-LABEL: bclri_i64_62:
620 ; RV64ZBS-NEXT: bclri a0, a0, 62
622 %and = and i64 %a, -4611686018427387905
626 define i64 @bclri_i64_63(i64 %a) nounwind {
627 ; RV64I-LABEL: bclri_i64_63:
629 ; RV64I-NEXT: slli a0, a0, 1
630 ; RV64I-NEXT: srli a0, a0, 1
633 ; RV64ZBS-LABEL: bclri_i64_63:
635 ; RV64ZBS-NEXT: bclri a0, a0, 63
637 %and = and i64 %a, -9223372036854775809
641 define i64 @bclri_i64_large0(i64 %a) nounwind {
642 ; RV64I-LABEL: bclri_i64_large0:
644 ; RV64I-NEXT: lui a1, 1044480
645 ; RV64I-NEXT: addiw a1, a1, -256
646 ; RV64I-NEXT: and a0, a0, a1
649 ; RV64ZBS-LABEL: bclri_i64_large0:
651 ; RV64ZBS-NEXT: andi a0, a0, -256
652 ; RV64ZBS-NEXT: bclri a0, a0, 24
654 %and = and i64 %a, -16777472
658 define i64 @bclri_i64_large1(i64 %a) nounwind {
659 ; RV64I-LABEL: bclri_i64_large1:
661 ; RV64I-NEXT: lui a1, 1044464
662 ; RV64I-NEXT: addiw a1, a1, -1
663 ; RV64I-NEXT: and a0, a0, a1
666 ; RV64ZBS-LABEL: bclri_i64_large1:
668 ; RV64ZBS-NEXT: bclri a0, a0, 16
669 ; RV64ZBS-NEXT: bclri a0, a0, 24
671 %and = and i64 %a, -16842753
675 define signext i32 @bseti_i32_10(i32 signext %a) nounwind {
676 ; CHECK-LABEL: bseti_i32_10:
678 ; CHECK-NEXT: ori a0, a0, 1024
680 %or = or i32 %a, 1024
684 define signext i32 @bseti_i32_11(i32 signext %a) nounwind {
685 ; RV64I-LABEL: bseti_i32_11:
687 ; RV64I-NEXT: li a1, 1
688 ; RV64I-NEXT: slli a1, a1, 11
689 ; RV64I-NEXT: or a0, a0, a1
692 ; RV64ZBS-LABEL: bseti_i32_11:
694 ; RV64ZBS-NEXT: bseti a0, a0, 11
696 %or = or i32 %a, 2048
700 define signext i32 @bseti_i32_30(i32 signext %a) nounwind {
701 ; RV64I-LABEL: bseti_i32_30:
703 ; RV64I-NEXT: lui a1, 262144
704 ; RV64I-NEXT: or a0, a0, a1
707 ; RV64ZBS-LABEL: bseti_i32_30:
709 ; RV64ZBS-NEXT: bseti a0, a0, 30
711 %or = or i32 %a, 1073741824
715 define signext i32 @bseti_i32_31(i32 signext %a) nounwind {
716 ; CHECK-LABEL: bseti_i32_31:
718 ; CHECK-NEXT: lui a1, 524288
719 ; CHECK-NEXT: or a0, a0, a1
721 %or = or i32 %a, 2147483648
725 define i64 @bseti_i64_10(i64 %a) nounwind {
726 ; CHECK-LABEL: bseti_i64_10:
728 ; CHECK-NEXT: ori a0, a0, 1024
730 %or = or i64 %a, 1024
734 define i64 @bseti_i64_11(i64 %a) nounwind {
735 ; RV64I-LABEL: bseti_i64_11:
737 ; RV64I-NEXT: li a1, 1
738 ; RV64I-NEXT: slli a1, a1, 11
739 ; RV64I-NEXT: or a0, a0, a1
742 ; RV64ZBS-LABEL: bseti_i64_11:
744 ; RV64ZBS-NEXT: bseti a0, a0, 11
746 %or = or i64 %a, 2048
750 define i64 @bseti_i64_30(i64 %a) nounwind {
751 ; RV64I-LABEL: bseti_i64_30:
753 ; RV64I-NEXT: lui a1, 262144
754 ; RV64I-NEXT: or a0, a0, a1
757 ; RV64ZBS-LABEL: bseti_i64_30:
759 ; RV64ZBS-NEXT: bseti a0, a0, 30
761 %or = or i64 %a, 1073741824
765 define i64 @bseti_i64_31(i64 %a) nounwind {
766 ; RV64I-LABEL: bseti_i64_31:
768 ; RV64I-NEXT: li a1, 1
769 ; RV64I-NEXT: slli a1, a1, 31
770 ; RV64I-NEXT: or a0, a0, a1
773 ; RV64ZBS-LABEL: bseti_i64_31:
775 ; RV64ZBS-NEXT: bseti a0, a0, 31
777 %or = or i64 %a, 2147483648
781 define i64 @bseti_i64_62(i64 %a) nounwind {
782 ; RV64I-LABEL: bseti_i64_62:
784 ; RV64I-NEXT: li a1, 1
785 ; RV64I-NEXT: slli a1, a1, 62
786 ; RV64I-NEXT: or a0, a0, a1
789 ; RV64ZBS-LABEL: bseti_i64_62:
791 ; RV64ZBS-NEXT: bseti a0, a0, 62
793 %or = or i64 %a, 4611686018427387904
797 define i64 @bseti_i64_63(i64 %a) nounwind {
798 ; RV64I-LABEL: bseti_i64_63:
800 ; RV64I-NEXT: li a1, -1
801 ; RV64I-NEXT: slli a1, a1, 63
802 ; RV64I-NEXT: or a0, a0, a1
805 ; RV64ZBS-LABEL: bseti_i64_63:
807 ; RV64ZBS-NEXT: bseti a0, a0, 63
809 %or = or i64 %a, 9223372036854775808
813 define signext i32 @binvi_i32_10(i32 signext %a) nounwind {
814 ; CHECK-LABEL: binvi_i32_10:
816 ; CHECK-NEXT: xori a0, a0, 1024
818 %xor = xor i32 %a, 1024
822 define signext i32 @binvi_i32_11(i32 signext %a) nounwind {
823 ; RV64I-LABEL: binvi_i32_11:
825 ; RV64I-NEXT: li a1, 1
826 ; RV64I-NEXT: slli a1, a1, 11
827 ; RV64I-NEXT: xor a0, a0, a1
830 ; RV64ZBS-LABEL: binvi_i32_11:
832 ; RV64ZBS-NEXT: binvi a0, a0, 11
834 %xor = xor i32 %a, 2048
838 define signext i32 @binvi_i32_30(i32 signext %a) nounwind {
839 ; RV64I-LABEL: binvi_i32_30:
841 ; RV64I-NEXT: lui a1, 262144
842 ; RV64I-NEXT: xor a0, a0, a1
845 ; RV64ZBS-LABEL: binvi_i32_30:
847 ; RV64ZBS-NEXT: binvi a0, a0, 30
849 %xor = xor i32 %a, 1073741824
853 define signext i32 @binvi_i32_31(i32 signext %a) nounwind {
854 ; CHECK-LABEL: binvi_i32_31:
856 ; CHECK-NEXT: lui a1, 524288
857 ; CHECK-NEXT: xor a0, a0, a1
859 %xor = xor i32 %a, 2147483648
863 define i64 @binvi_i64_10(i64 %a) nounwind {
864 ; CHECK-LABEL: binvi_i64_10:
866 ; CHECK-NEXT: xori a0, a0, 1024
868 %xor = xor i64 %a, 1024
872 define i64 @binvi_i64_11(i64 %a) nounwind {
873 ; RV64I-LABEL: binvi_i64_11:
875 ; RV64I-NEXT: li a1, 1
876 ; RV64I-NEXT: slli a1, a1, 11
877 ; RV64I-NEXT: xor a0, a0, a1
880 ; RV64ZBS-LABEL: binvi_i64_11:
882 ; RV64ZBS-NEXT: binvi a0, a0, 11
884 %xor = xor i64 %a, 2048
888 define i64 @binvi_i64_30(i64 %a) nounwind {
889 ; RV64I-LABEL: binvi_i64_30:
891 ; RV64I-NEXT: lui a1, 262144
892 ; RV64I-NEXT: xor a0, a0, a1
895 ; RV64ZBS-LABEL: binvi_i64_30:
897 ; RV64ZBS-NEXT: binvi a0, a0, 30
899 %xor = xor i64 %a, 1073741824
903 define i64 @binvi_i64_31(i64 %a) nounwind {
904 ; RV64I-LABEL: binvi_i64_31:
906 ; RV64I-NEXT: li a1, 1
907 ; RV64I-NEXT: slli a1, a1, 31
908 ; RV64I-NEXT: xor a0, a0, a1
911 ; RV64ZBS-LABEL: binvi_i64_31:
913 ; RV64ZBS-NEXT: binvi a0, a0, 31
915 %xor = xor i64 %a, 2147483648
919 define i64 @binvi_i64_62(i64 %a) nounwind {
920 ; RV64I-LABEL: binvi_i64_62:
922 ; RV64I-NEXT: li a1, 1
923 ; RV64I-NEXT: slli a1, a1, 62
924 ; RV64I-NEXT: xor a0, a0, a1
927 ; RV64ZBS-LABEL: binvi_i64_62:
929 ; RV64ZBS-NEXT: binvi a0, a0, 62
931 %xor = xor i64 %a, 4611686018427387904
935 define i64 @binvi_i64_63(i64 %a) nounwind {
936 ; RV64I-LABEL: binvi_i64_63:
938 ; RV64I-NEXT: li a1, -1
939 ; RV64I-NEXT: slli a1, a1, 63
940 ; RV64I-NEXT: xor a0, a0, a1
943 ; RV64ZBS-LABEL: binvi_i64_63:
945 ; RV64ZBS-NEXT: binvi a0, a0, 63
947 %xor = xor i64 %a, 9223372036854775808
951 define i64 @xor_i64_large(i64 %a) nounwind {
952 ; RV64I-LABEL: xor_i64_large:
954 ; RV64I-NEXT: li a1, 1
955 ; RV64I-NEXT: slli a1, a1, 32
956 ; RV64I-NEXT: addi a1, a1, 1
957 ; RV64I-NEXT: xor a0, a0, a1
960 ; RV64ZBS-LABEL: xor_i64_large:
962 ; RV64ZBS-NEXT: binvi a0, a0, 0
963 ; RV64ZBS-NEXT: binvi a0, a0, 32
965 %xor = xor i64 %a, 4294967297
969 define i64 @xor_i64_4099(i64 %a) nounwind {
970 ; RV64I-LABEL: xor_i64_4099:
972 ; RV64I-NEXT: lui a1, 1
973 ; RV64I-NEXT: addiw a1, a1, 3
974 ; RV64I-NEXT: xor a0, a0, a1
977 ; RV64ZBS-LABEL: xor_i64_4099:
979 ; RV64ZBS-NEXT: xori a0, a0, 3
980 ; RV64ZBS-NEXT: binvi a0, a0, 12
982 %xor = xor i64 %a, 4099
986 define i64 @xor_i64_96(i64 %a) nounwind {
987 ; CHECK-LABEL: xor_i64_96:
989 ; CHECK-NEXT: xori a0, a0, 96
991 %xor = xor i64 %a, 96
995 define i64 @or_i64_large(i64 %a) nounwind {
996 ; RV64I-LABEL: or_i64_large:
998 ; RV64I-NEXT: li a1, 1
999 ; RV64I-NEXT: slli a1, a1, 32
1000 ; RV64I-NEXT: addi a1, a1, 1
1001 ; RV64I-NEXT: or a0, a0, a1
1004 ; RV64ZBS-LABEL: or_i64_large:
1006 ; RV64ZBS-NEXT: bseti a0, a0, 0
1007 ; RV64ZBS-NEXT: bseti a0, a0, 32
1009 %or = or i64 %a, 4294967297
1013 define i64 @xor_i64_66901(i64 %a) nounwind {
1014 ; RV64I-LABEL: xor_i64_66901:
1016 ; RV64I-NEXT: lui a1, 16
1017 ; RV64I-NEXT: addiw a1, a1, 1365
1018 ; RV64I-NEXT: xor a0, a0, a1
1021 ; RV64ZBS-LABEL: xor_i64_66901:
1023 ; RV64ZBS-NEXT: xori a0, a0, 1365
1024 ; RV64ZBS-NEXT: binvi a0, a0, 16
1026 %xor = xor i64 %a, 66901
1030 define i64 @or_i64_4099(i64 %a) nounwind {
1031 ; RV64I-LABEL: or_i64_4099:
1033 ; RV64I-NEXT: lui a1, 1
1034 ; RV64I-NEXT: addiw a1, a1, 3
1035 ; RV64I-NEXT: or a0, a0, a1
1038 ; RV64ZBS-LABEL: or_i64_4099:
1040 ; RV64ZBS-NEXT: ori a0, a0, 3
1041 ; RV64ZBS-NEXT: bseti a0, a0, 12
1043 %or = or i64 %a, 4099
1047 define i64 @or_i64_96(i64 %a) nounwind {
1048 ; CHECK-LABEL: or_i64_96:
1050 ; CHECK-NEXT: ori a0, a0, 96
1056 define i64 @or_i64_66901(i64 %a) nounwind {
1057 ; RV64I-LABEL: or_i64_66901:
1059 ; RV64I-NEXT: lui a1, 16
1060 ; RV64I-NEXT: addiw a1, a1, 1365
1061 ; RV64I-NEXT: or a0, a0, a1
1064 ; RV64ZBS-LABEL: or_i64_66901:
1066 ; RV64ZBS-NEXT: ori a0, a0, 1365
1067 ; RV64ZBS-NEXT: bseti a0, a0, 16
1069 %or = or i64 %a, 66901