1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: -riscv-experimental-rv64-legal-i32 | FileCheck %s -check-prefixes=CHECK,RV64I
4 ; RUN: llc -mtriple=riscv64 -mattr=+zbs -verify-machineinstrs < %s \
5 ; RUN: -riscv-experimental-rv64-legal-i32 | FileCheck %s -check-prefixes=CHECK,RV64ZBS
7 define signext i32 @bclr_i32(i32 signext %a, i32 signext %b) nounwind {
8 ; CHECK-LABEL: bclr_i32:
10 ; CHECK-NEXT: li a2, 1
11 ; CHECK-NEXT: sllw a1, a2, a1
12 ; CHECK-NEXT: not a1, a1
13 ; CHECK-NEXT: and a0, a1, a0
16 %shl = shl nuw i32 1, %and
17 %neg = xor i32 %shl, -1
18 %and1 = and i32 %neg, %a
22 define signext i32 @bclr_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
23 ; CHECK-LABEL: bclr_i32_no_mask:
25 ; CHECK-NEXT: li a2, 1
26 ; CHECK-NEXT: sllw a1, a2, a1
27 ; CHECK-NEXT: not a1, a1
28 ; CHECK-NEXT: and a0, a1, a0
31 %neg = xor i32 %shl, -1
32 %and1 = and i32 %neg, %a
36 define signext i32 @bclr_i32_load(ptr %p, i32 signext %b) nounwind {
37 ; CHECK-LABEL: bclr_i32_load:
39 ; CHECK-NEXT: lw a0, 0(a0)
40 ; CHECK-NEXT: li a2, 1
41 ; CHECK-NEXT: sllw a1, a2, a1
42 ; CHECK-NEXT: not a1, a1
43 ; CHECK-NEXT: and a0, a1, a0
47 %neg = xor i32 %shl, -1
48 %and1 = and i32 %neg, %a
52 define i64 @bclr_i64(i64 %a, i64 %b) nounwind {
53 ; RV64I-LABEL: bclr_i64:
55 ; RV64I-NEXT: li a2, 1
56 ; RV64I-NEXT: sll a1, a2, a1
57 ; RV64I-NEXT: not a1, a1
58 ; RV64I-NEXT: and a0, a1, a0
61 ; RV64ZBS-LABEL: bclr_i64:
63 ; RV64ZBS-NEXT: bclr a0, a0, a1
66 %shl = shl nuw i64 1, %and
67 %neg = xor i64 %shl, -1
68 %and1 = and i64 %neg, %a
72 define i64 @bclr_i64_no_mask(i64 %a, i64 %b) nounwind {
73 ; RV64I-LABEL: bclr_i64_no_mask:
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_no_mask:
83 ; RV64ZBS-NEXT: bclr a0, a0, a1
86 %neg = xor i64 %shl, -1
87 %and1 = and i64 %neg, %a
91 define signext i32 @bset_i32(i32 signext %a, i32 signext %b) nounwind {
92 ; CHECK-LABEL: bset_i32:
94 ; CHECK-NEXT: li a2, 1
95 ; CHECK-NEXT: sllw a1, a2, a1
96 ; CHECK-NEXT: or a0, a1, a0
99 %shl = shl nuw i32 1, %and
100 %or = or i32 %shl, %a
104 define signext i32 @bset_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
105 ; CHECK-LABEL: bset_i32_no_mask:
107 ; CHECK-NEXT: li a2, 1
108 ; CHECK-NEXT: sllw a1, a2, a1
109 ; CHECK-NEXT: or a0, a1, a0
112 %or = or i32 %shl, %a
116 define signext i32 @bset_i32_load(ptr %p, i32 signext %b) nounwind {
117 ; CHECK-LABEL: bset_i32_load:
119 ; CHECK-NEXT: lw a0, 0(a0)
120 ; CHECK-NEXT: li a2, 1
121 ; CHECK-NEXT: sllw a1, a2, a1
122 ; CHECK-NEXT: or a0, a1, a0
124 %a = load i32, ptr %p
126 %or = or i32 %shl, %a
130 ; We can use bsetw for 1 << x by setting the first source to zero.
131 define signext i32 @bset_i32_zero(i32 signext %a) nounwind {
132 ; CHECK-LABEL: bset_i32_zero:
134 ; CHECK-NEXT: li a1, 1
135 ; CHECK-NEXT: sllw a0, a1, a0
141 define i64 @bset_i64(i64 %a, i64 %b) nounwind {
142 ; RV64I-LABEL: bset_i64:
144 ; RV64I-NEXT: li a2, 1
145 ; RV64I-NEXT: sll a1, a2, a1
146 ; RV64I-NEXT: or a0, a1, a0
149 ; RV64ZBS-LABEL: bset_i64:
151 ; RV64ZBS-NEXT: bset a0, a0, a1
153 %conv = and i64 %b, 63
154 %shl = shl nuw i64 1, %conv
155 %or = or i64 %shl, %a
159 define i64 @bset_i64_no_mask(i64 %a, i64 %b) nounwind {
160 ; RV64I-LABEL: bset_i64_no_mask:
162 ; RV64I-NEXT: li a2, 1
163 ; RV64I-NEXT: sll a1, a2, a1
164 ; RV64I-NEXT: or a0, a1, a0
167 ; RV64ZBS-LABEL: bset_i64_no_mask:
169 ; RV64ZBS-NEXT: bset a0, a0, a1
172 %or = or i64 %shl, %a
176 ; We can use bsetw for 1 << x by setting the first source to zero.
177 define signext i64 @bset_i64_zero(i64 signext %a) nounwind {
178 ; RV64I-LABEL: bset_i64_zero:
180 ; RV64I-NEXT: li a1, 1
181 ; RV64I-NEXT: sll a0, a1, a0
184 ; RV64ZBS-LABEL: bset_i64_zero:
186 ; RV64ZBS-NEXT: bset a0, zero, a0
192 define signext i32 @binv_i32(i32 signext %a, i32 signext %b) nounwind {
193 ; CHECK-LABEL: binv_i32:
195 ; CHECK-NEXT: li a2, 1
196 ; CHECK-NEXT: sllw a1, a2, a1
197 ; CHECK-NEXT: xor a0, a1, a0
199 %and = and i32 %b, 31
200 %shl = shl nuw i32 1, %and
201 %xor = xor i32 %shl, %a
205 define signext i32 @binv_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
206 ; CHECK-LABEL: binv_i32_no_mask:
208 ; CHECK-NEXT: li a2, 1
209 ; CHECK-NEXT: sllw a1, a2, a1
210 ; CHECK-NEXT: xor a0, a1, a0
213 %xor = xor i32 %shl, %a
217 define signext i32 @binv_i32_load(ptr %p, i32 signext %b) nounwind {
218 ; CHECK-LABEL: binv_i32_load:
220 ; CHECK-NEXT: lw a0, 0(a0)
221 ; CHECK-NEXT: li a2, 1
222 ; CHECK-NEXT: sllw a1, a2, a1
223 ; CHECK-NEXT: xor a0, a1, a0
225 %a = load i32, ptr %p
227 %xor = xor i32 %shl, %a
231 define i64 @binv_i64(i64 %a, i64 %b) nounwind {
232 ; RV64I-LABEL: binv_i64:
234 ; RV64I-NEXT: li a2, 1
235 ; RV64I-NEXT: sll a1, a2, a1
236 ; RV64I-NEXT: xor a0, a1, a0
239 ; RV64ZBS-LABEL: binv_i64:
241 ; RV64ZBS-NEXT: binv a0, a0, a1
243 %conv = and i64 %b, 63
244 %shl = shl nuw i64 1, %conv
245 %xor = xor i64 %shl, %a
249 define i64 @binv_i64_no_mask(i64 %a, i64 %b) nounwind {
250 ; RV64I-LABEL: binv_i64_no_mask:
252 ; RV64I-NEXT: li a2, 1
253 ; RV64I-NEXT: sll a1, a2, a1
254 ; RV64I-NEXT: xor a0, a1, a0
257 ; RV64ZBS-LABEL: binv_i64_no_mask:
259 ; RV64ZBS-NEXT: binv a0, a0, a1
261 %shl = shl nuw i64 1, %b
262 %xor = xor i64 %shl, %a
266 define signext i32 @bext_i32(i32 signext %a, i32 signext %b) nounwind {
267 ; RV64I-LABEL: bext_i32:
269 ; RV64I-NEXT: srlw a0, a0, a1
270 ; RV64I-NEXT: andi a0, a0, 1
273 ; RV64ZBS-LABEL: bext_i32:
275 ; RV64ZBS-NEXT: andi a1, a1, 31
276 ; RV64ZBS-NEXT: srl a0, a0, a1
277 ; RV64ZBS-NEXT: andi a0, a0, 1
279 %and = and i32 %b, 31
280 %shr = lshr i32 %a, %and
281 %and1 = and i32 %shr, 1
285 define signext i32 @bext_i32_no_mask(i32 signext %a, i32 signext %b) nounwind {
286 ; RV64I-LABEL: bext_i32_no_mask:
288 ; RV64I-NEXT: srlw a0, a0, a1
289 ; RV64I-NEXT: andi a0, a0, 1
292 ; RV64ZBS-LABEL: bext_i32_no_mask:
294 ; RV64ZBS-NEXT: srl a0, a0, a1
295 ; RV64ZBS-NEXT: andi a0, a0, 1
297 %shr = lshr i32 %a, %b
298 %and1 = and i32 %shr, 1
302 ; This gets previous converted to (i1 (truncate (srl X, Y)). Make sure we are
304 define void @bext_i32_trunc(i32 signext %0, i32 signext %1) {
305 ; RV64I-LABEL: bext_i32_trunc:
307 ; RV64I-NEXT: srlw a0, a0, a1
308 ; RV64I-NEXT: andi a0, a0, 1
309 ; RV64I-NEXT: beqz a0, .LBB19_2
310 ; RV64I-NEXT: # %bb.1:
312 ; RV64I-NEXT: .LBB19_2:
313 ; RV64I-NEXT: tail bar@plt
315 ; RV64ZBS-LABEL: bext_i32_trunc:
317 ; RV64ZBS-NEXT: bext a0, a0, a1
318 ; RV64ZBS-NEXT: beqz a0, .LBB19_2
319 ; RV64ZBS-NEXT: # %bb.1:
321 ; RV64ZBS-NEXT: .LBB19_2:
322 ; RV64ZBS-NEXT: tail bar@plt
325 %5 = icmp eq i32 %4, 0
326 br i1 %5, label %6, label %7
329 tail call void @bar()
338 define i64 @bext_i64(i64 %a, i64 %b) nounwind {
339 ; RV64I-LABEL: bext_i64:
341 ; RV64I-NEXT: srl a0, a0, a1
342 ; RV64I-NEXT: andi a0, a0, 1
345 ; RV64ZBS-LABEL: bext_i64:
347 ; RV64ZBS-NEXT: bext a0, a0, a1
349 %conv = and i64 %b, 63
350 %shr = lshr i64 %a, %conv
351 %and1 = and i64 %shr, 1
355 define i64 @bext_i64_no_mask(i64 %a, i64 %b) nounwind {
356 ; RV64I-LABEL: bext_i64_no_mask:
358 ; RV64I-NEXT: srl a0, a0, a1
359 ; RV64I-NEXT: andi a0, a0, 1
362 ; RV64ZBS-LABEL: bext_i64_no_mask:
364 ; RV64ZBS-NEXT: bext a0, a0, a1
366 %shr = lshr i64 %a, %b
367 %and1 = and i64 %shr, 1
371 define signext i32 @bexti_i32(i32 signext %a) nounwind {
372 ; RV64I-LABEL: bexti_i32:
374 ; RV64I-NEXT: slli a0, a0, 58
375 ; RV64I-NEXT: srli a0, a0, 63
378 ; RV64ZBS-LABEL: bexti_i32:
380 ; RV64ZBS-NEXT: srliw a0, a0, 5
381 ; RV64ZBS-NEXT: andi a0, a0, 1
383 %shr = lshr i32 %a, 5
384 %and = and i32 %shr, 1
388 define i64 @bexti_i64(i64 %a) nounwind {
389 ; RV64I-LABEL: bexti_i64:
391 ; RV64I-NEXT: slli a0, a0, 58
392 ; RV64I-NEXT: srli a0, a0, 63
395 ; RV64ZBS-LABEL: bexti_i64:
397 ; RV64ZBS-NEXT: bexti a0, a0, 5
399 %shr = lshr i64 %a, 5
400 %and = and i64 %shr, 1
404 define signext i32 @bexti_i32_cmp(i32 signext %a) nounwind {
405 ; CHECK-LABEL: bexti_i32_cmp:
407 ; CHECK-NEXT: andi a0, a0, 32
408 ; CHECK-NEXT: snez a0, a0
410 %and = and i32 %a, 32
411 %cmp = icmp ne i32 %and, 0
412 %zext = zext i1 %cmp to i32
416 define i64 @bexti_i64_cmp(i64 %a) nounwind {
417 ; RV64I-LABEL: bexti_i64_cmp:
419 ; RV64I-NEXT: slli a0, a0, 58
420 ; RV64I-NEXT: srli a0, a0, 63
423 ; RV64ZBS-LABEL: bexti_i64_cmp:
425 ; RV64ZBS-NEXT: bexti a0, a0, 5
427 %and = and i64 %a, 32
428 %cmp = icmp ne i64 %and, 0
429 %zext = zext i1 %cmp to i64
433 define signext i32 @bclri_i32_10(i32 signext %a) nounwind {
434 ; CHECK-LABEL: bclri_i32_10:
436 ; CHECK-NEXT: andi a0, a0, -1025
438 %and = and i32 %a, -1025
442 define signext i32 @bclri_i32_11(i32 signext %a) nounwind {
443 ; CHECK-LABEL: bclri_i32_11:
445 ; CHECK-NEXT: lui a1, 1048575
446 ; CHECK-NEXT: addiw a1, a1, 2047
447 ; CHECK-NEXT: and a0, a0, a1
449 %and = and i32 %a, -2049
453 define signext i32 @bclri_i32_30(i32 signext %a) nounwind {
454 ; CHECK-LABEL: bclri_i32_30:
456 ; CHECK-NEXT: lui a1, 786432
457 ; CHECK-NEXT: addiw a1, a1, -1
458 ; CHECK-NEXT: and a0, a0, a1
460 %and = and i32 %a, -1073741825
464 define signext i32 @bclri_i32_31(i32 signext %a) nounwind {
465 ; CHECK-LABEL: bclri_i32_31:
467 ; CHECK-NEXT: lui a1, 524288
468 ; CHECK-NEXT: addiw a1, a1, -1
469 ; CHECK-NEXT: and a0, a0, a1
471 %and = and i32 %a, -2147483649
475 define i64 @bclri_i64_10(i64 %a) nounwind {
476 ; CHECK-LABEL: bclri_i64_10:
478 ; CHECK-NEXT: andi a0, a0, -1025
480 %and = and i64 %a, -1025
484 define i64 @bclri_i64_11(i64 %a) nounwind {
485 ; RV64I-LABEL: bclri_i64_11:
487 ; RV64I-NEXT: lui a1, 1048575
488 ; RV64I-NEXT: addiw a1, a1, 2047
489 ; RV64I-NEXT: and a0, a0, a1
492 ; RV64ZBS-LABEL: bclri_i64_11:
494 ; RV64ZBS-NEXT: bclri a0, a0, 11
496 %and = and i64 %a, -2049
500 define i64 @bclri_i64_30(i64 %a) nounwind {
501 ; RV64I-LABEL: bclri_i64_30:
503 ; RV64I-NEXT: lui a1, 786432
504 ; RV64I-NEXT: addiw a1, a1, -1
505 ; RV64I-NEXT: and a0, a0, a1
508 ; RV64ZBS-LABEL: bclri_i64_30:
510 ; RV64ZBS-NEXT: bclri a0, a0, 30
512 %and = and i64 %a, -1073741825
516 define i64 @bclri_i64_31(i64 %a) nounwind {
517 ; RV64I-LABEL: bclri_i64_31:
519 ; RV64I-NEXT: lui a1, 524288
520 ; RV64I-NEXT: addi a1, a1, -1
521 ; RV64I-NEXT: and a0, a0, a1
524 ; RV64ZBS-LABEL: bclri_i64_31:
526 ; RV64ZBS-NEXT: bclri a0, a0, 31
528 %and = and i64 %a, -2147483649
532 define i64 @bclri_i64_62(i64 %a) nounwind {
533 ; RV64I-LABEL: bclri_i64_62:
535 ; RV64I-NEXT: li a1, -1
536 ; RV64I-NEXT: slli a1, a1, 62
537 ; RV64I-NEXT: addi a1, a1, -1
538 ; RV64I-NEXT: and a0, a0, a1
541 ; RV64ZBS-LABEL: bclri_i64_62:
543 ; RV64ZBS-NEXT: bclri a0, a0, 62
545 %and = and i64 %a, -4611686018427387905
549 define i64 @bclri_i64_63(i64 %a) nounwind {
550 ; RV64I-LABEL: bclri_i64_63:
552 ; RV64I-NEXT: slli a0, a0, 1
553 ; RV64I-NEXT: srli a0, a0, 1
556 ; RV64ZBS-LABEL: bclri_i64_63:
558 ; RV64ZBS-NEXT: bclri a0, a0, 63
560 %and = and i64 %a, -9223372036854775809
564 define i64 @bclri_i64_large0(i64 %a) nounwind {
565 ; RV64I-LABEL: bclri_i64_large0:
567 ; RV64I-NEXT: lui a1, 1044480
568 ; RV64I-NEXT: addiw a1, a1, -256
569 ; RV64I-NEXT: and a0, a0, a1
572 ; RV64ZBS-LABEL: bclri_i64_large0:
574 ; RV64ZBS-NEXT: andi a0, a0, -256
575 ; RV64ZBS-NEXT: bclri a0, a0, 24
577 %and = and i64 %a, -16777472
581 define i64 @bclri_i64_large1(i64 %a) nounwind {
582 ; RV64I-LABEL: bclri_i64_large1:
584 ; RV64I-NEXT: lui a1, 1044464
585 ; RV64I-NEXT: addiw a1, a1, -1
586 ; RV64I-NEXT: and a0, a0, a1
589 ; RV64ZBS-LABEL: bclri_i64_large1:
591 ; RV64ZBS-NEXT: bclri a0, a0, 16
592 ; RV64ZBS-NEXT: bclri a0, a0, 24
594 %and = and i64 %a, -16842753
598 define signext i32 @bseti_i32_10(i32 signext %a) nounwind {
599 ; CHECK-LABEL: bseti_i32_10:
601 ; CHECK-NEXT: ori a0, a0, 1024
603 %or = or i32 %a, 1024
607 define signext i32 @bseti_i32_11(i32 signext %a) nounwind {
608 ; RV64I-LABEL: bseti_i32_11:
610 ; RV64I-NEXT: li a1, 1
611 ; RV64I-NEXT: slliw a1, a1, 11
612 ; RV64I-NEXT: or a0, a0, a1
615 ; RV64ZBS-LABEL: bseti_i32_11:
617 ; RV64ZBS-NEXT: bseti a1, zero, 11
618 ; RV64ZBS-NEXT: or a0, a0, a1
619 ; RV64ZBS-NEXT: sext.w a0, a0
621 %or = or i32 %a, 2048
625 define signext i32 @bseti_i32_30(i32 signext %a) nounwind {
626 ; CHECK-LABEL: bseti_i32_30:
628 ; CHECK-NEXT: lui a1, 262144
629 ; CHECK-NEXT: or a0, a0, a1
631 %or = or i32 %a, 1073741824
635 define signext i32 @bseti_i32_31(i32 signext %a) nounwind {
636 ; CHECK-LABEL: bseti_i32_31:
638 ; CHECK-NEXT: lui a1, 524288
639 ; CHECK-NEXT: or a0, a0, a1
641 %or = or i32 %a, 2147483648
645 define i64 @bseti_i64_10(i64 %a) nounwind {
646 ; CHECK-LABEL: bseti_i64_10:
648 ; CHECK-NEXT: ori a0, a0, 1024
650 %or = or i64 %a, 1024
654 define i64 @bseti_i64_11(i64 %a) nounwind {
655 ; RV64I-LABEL: bseti_i64_11:
657 ; RV64I-NEXT: li a1, 1
658 ; RV64I-NEXT: slli a1, a1, 11
659 ; RV64I-NEXT: or a0, a0, a1
662 ; RV64ZBS-LABEL: bseti_i64_11:
664 ; RV64ZBS-NEXT: bseti a0, a0, 11
666 %or = or i64 %a, 2048
670 define i64 @bseti_i64_30(i64 %a) nounwind {
671 ; RV64I-LABEL: bseti_i64_30:
673 ; RV64I-NEXT: lui a1, 262144
674 ; RV64I-NEXT: or a0, a0, a1
677 ; RV64ZBS-LABEL: bseti_i64_30:
679 ; RV64ZBS-NEXT: bseti a0, a0, 30
681 %or = or i64 %a, 1073741824
685 define i64 @bseti_i64_31(i64 %a) nounwind {
686 ; RV64I-LABEL: bseti_i64_31:
688 ; RV64I-NEXT: li a1, 1
689 ; RV64I-NEXT: slli a1, a1, 31
690 ; RV64I-NEXT: or a0, a0, a1
693 ; RV64ZBS-LABEL: bseti_i64_31:
695 ; RV64ZBS-NEXT: bseti a0, a0, 31
697 %or = or i64 %a, 2147483648
701 define i64 @bseti_i64_62(i64 %a) nounwind {
702 ; RV64I-LABEL: bseti_i64_62:
704 ; RV64I-NEXT: li a1, 1
705 ; RV64I-NEXT: slli a1, a1, 62
706 ; RV64I-NEXT: or a0, a0, a1
709 ; RV64ZBS-LABEL: bseti_i64_62:
711 ; RV64ZBS-NEXT: bseti a0, a0, 62
713 %or = or i64 %a, 4611686018427387904
717 define i64 @bseti_i64_63(i64 %a) nounwind {
718 ; RV64I-LABEL: bseti_i64_63:
720 ; RV64I-NEXT: li a1, -1
721 ; RV64I-NEXT: slli a1, a1, 63
722 ; RV64I-NEXT: or a0, a0, a1
725 ; RV64ZBS-LABEL: bseti_i64_63:
727 ; RV64ZBS-NEXT: bseti a0, a0, 63
729 %or = or i64 %a, 9223372036854775808
733 define signext i32 @binvi_i32_10(i32 signext %a) nounwind {
734 ; CHECK-LABEL: binvi_i32_10:
736 ; CHECK-NEXT: xori a0, a0, 1024
738 %xor = xor i32 %a, 1024
742 define signext i32 @binvi_i32_11(i32 signext %a) nounwind {
743 ; RV64I-LABEL: binvi_i32_11:
745 ; RV64I-NEXT: li a1, 1
746 ; RV64I-NEXT: slliw a1, a1, 11
747 ; RV64I-NEXT: xor a0, a0, a1
750 ; RV64ZBS-LABEL: binvi_i32_11:
752 ; RV64ZBS-NEXT: bseti a1, zero, 11
753 ; RV64ZBS-NEXT: xor a0, a0, a1
754 ; RV64ZBS-NEXT: sext.w a0, a0
756 %xor = xor i32 %a, 2048
760 define signext i32 @binvi_i32_30(i32 signext %a) nounwind {
761 ; CHECK-LABEL: binvi_i32_30:
763 ; CHECK-NEXT: lui a1, 262144
764 ; CHECK-NEXT: xor a0, a0, a1
766 %xor = xor i32 %a, 1073741824
770 define signext i32 @binvi_i32_31(i32 signext %a) nounwind {
771 ; CHECK-LABEL: binvi_i32_31:
773 ; CHECK-NEXT: lui a1, 524288
774 ; CHECK-NEXT: xor a0, a0, a1
776 %xor = xor i32 %a, 2147483648
780 define i64 @binvi_i64_10(i64 %a) nounwind {
781 ; CHECK-LABEL: binvi_i64_10:
783 ; CHECK-NEXT: xori a0, a0, 1024
785 %xor = xor i64 %a, 1024
789 define i64 @binvi_i64_11(i64 %a) nounwind {
790 ; RV64I-LABEL: binvi_i64_11:
792 ; RV64I-NEXT: li a1, 1
793 ; RV64I-NEXT: slli a1, a1, 11
794 ; RV64I-NEXT: xor a0, a0, a1
797 ; RV64ZBS-LABEL: binvi_i64_11:
799 ; RV64ZBS-NEXT: binvi a0, a0, 11
801 %xor = xor i64 %a, 2048
805 define i64 @binvi_i64_30(i64 %a) nounwind {
806 ; RV64I-LABEL: binvi_i64_30:
808 ; RV64I-NEXT: lui a1, 262144
809 ; RV64I-NEXT: xor a0, a0, a1
812 ; RV64ZBS-LABEL: binvi_i64_30:
814 ; RV64ZBS-NEXT: binvi a0, a0, 30
816 %xor = xor i64 %a, 1073741824
820 define i64 @binvi_i64_31(i64 %a) nounwind {
821 ; RV64I-LABEL: binvi_i64_31:
823 ; RV64I-NEXT: li a1, 1
824 ; RV64I-NEXT: slli a1, a1, 31
825 ; RV64I-NEXT: xor a0, a0, a1
828 ; RV64ZBS-LABEL: binvi_i64_31:
830 ; RV64ZBS-NEXT: binvi a0, a0, 31
832 %xor = xor i64 %a, 2147483648
836 define i64 @binvi_i64_62(i64 %a) nounwind {
837 ; RV64I-LABEL: binvi_i64_62:
839 ; RV64I-NEXT: li a1, 1
840 ; RV64I-NEXT: slli a1, a1, 62
841 ; RV64I-NEXT: xor a0, a0, a1
844 ; RV64ZBS-LABEL: binvi_i64_62:
846 ; RV64ZBS-NEXT: binvi a0, a0, 62
848 %xor = xor i64 %a, 4611686018427387904
852 define i64 @binvi_i64_63(i64 %a) nounwind {
853 ; RV64I-LABEL: binvi_i64_63:
855 ; RV64I-NEXT: li a1, -1
856 ; RV64I-NEXT: slli a1, a1, 63
857 ; RV64I-NEXT: xor a0, a0, a1
860 ; RV64ZBS-LABEL: binvi_i64_63:
862 ; RV64ZBS-NEXT: binvi a0, a0, 63
864 %xor = xor i64 %a, 9223372036854775808
868 define i64 @xor_i64_large(i64 %a) nounwind {
869 ; RV64I-LABEL: xor_i64_large:
871 ; RV64I-NEXT: li a1, 1
872 ; RV64I-NEXT: slli a1, a1, 32
873 ; RV64I-NEXT: addi a1, a1, 1
874 ; RV64I-NEXT: xor a0, a0, a1
877 ; RV64ZBS-LABEL: xor_i64_large:
879 ; RV64ZBS-NEXT: binvi a0, a0, 0
880 ; RV64ZBS-NEXT: binvi a0, a0, 32
882 %xor = xor i64 %a, 4294967297
886 define i64 @xor_i64_4099(i64 %a) nounwind {
887 ; RV64I-LABEL: xor_i64_4099:
889 ; RV64I-NEXT: lui a1, 1
890 ; RV64I-NEXT: addiw a1, a1, 3
891 ; RV64I-NEXT: xor a0, a0, a1
894 ; RV64ZBS-LABEL: xor_i64_4099:
896 ; RV64ZBS-NEXT: xori a0, a0, 3
897 ; RV64ZBS-NEXT: binvi a0, a0, 12
899 %xor = xor i64 %a, 4099
903 define i64 @xor_i64_96(i64 %a) nounwind {
904 ; CHECK-LABEL: xor_i64_96:
906 ; CHECK-NEXT: xori a0, a0, 96
908 %xor = xor i64 %a, 96
912 define i64 @or_i64_large(i64 %a) nounwind {
913 ; RV64I-LABEL: or_i64_large:
915 ; RV64I-NEXT: li a1, 1
916 ; RV64I-NEXT: slli a1, a1, 32
917 ; RV64I-NEXT: addi a1, a1, 1
918 ; RV64I-NEXT: or a0, a0, a1
921 ; RV64ZBS-LABEL: or_i64_large:
923 ; RV64ZBS-NEXT: bseti a0, a0, 0
924 ; RV64ZBS-NEXT: bseti a0, a0, 32
926 %or = or i64 %a, 4294967297
930 define i64 @xor_i64_66901(i64 %a) nounwind {
931 ; RV64I-LABEL: xor_i64_66901:
933 ; RV64I-NEXT: lui a1, 16
934 ; RV64I-NEXT: addiw a1, a1, 1365
935 ; RV64I-NEXT: xor a0, a0, a1
938 ; RV64ZBS-LABEL: xor_i64_66901:
940 ; RV64ZBS-NEXT: xori a0, a0, 1365
941 ; RV64ZBS-NEXT: binvi a0, a0, 16
943 %xor = xor i64 %a, 66901
947 define i64 @or_i64_4099(i64 %a) nounwind {
948 ; RV64I-LABEL: or_i64_4099:
950 ; RV64I-NEXT: lui a1, 1
951 ; RV64I-NEXT: addiw a1, a1, 3
952 ; RV64I-NEXT: or a0, a0, a1
955 ; RV64ZBS-LABEL: or_i64_4099:
957 ; RV64ZBS-NEXT: ori a0, a0, 3
958 ; RV64ZBS-NEXT: bseti a0, a0, 12
960 %or = or i64 %a, 4099
964 define i64 @or_i64_96(i64 %a) nounwind {
965 ; CHECK-LABEL: or_i64_96:
967 ; CHECK-NEXT: ori a0, a0, 96
973 define i64 @or_i64_66901(i64 %a) nounwind {
974 ; RV64I-LABEL: or_i64_66901:
976 ; RV64I-NEXT: lui a1, 16
977 ; RV64I-NEXT: addiw a1, a1, 1365
978 ; RV64I-NEXT: or a0, a0, a1
981 ; RV64ZBS-LABEL: or_i64_66901:
983 ; RV64ZBS-NEXT: ori a0, a0, 1365
984 ; RV64ZBS-NEXT: bseti a0, a0, 16
986 %or = or i64 %a, 66901