1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+zbb -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64ZBB
4 ; RUN: llc -mtriple=riscv64 -mattr=+zbb,+experimental-zbp -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64ZBP
7 declare i32 @llvm.riscv.orc.b.i32(i32)
9 define signext i32 @orcb32(i32 signext %a) nounwind {
10 ; RV64ZBB-LABEL: orcb32:
12 ; RV64ZBB-NEXT: orc.b a0, a0
13 ; RV64ZBB-NEXT: sext.w a0, a0
16 ; RV64ZBP-LABEL: orcb32:
18 ; RV64ZBP-NEXT: gorciw a0, a0, 7
20 %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
24 define zeroext i32 @orcb32_zext(i32 zeroext %a) nounwind {
25 ; RV64ZBB-LABEL: orcb32_zext:
27 ; RV64ZBB-NEXT: orc.b a0, a0
30 ; RV64ZBP-LABEL: orcb32_zext:
32 ; RV64ZBP-NEXT: orc.b a0, a0
34 %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
38 ; Second and+or is redundant with the first, make sure we remove them.
39 define signext i32 @orcb32_knownbits(i32 signext %a) nounwind {
40 ; RV64ZBB-LABEL: orcb32_knownbits:
42 ; RV64ZBB-NEXT: lui a1, 1044480
43 ; RV64ZBB-NEXT: and a0, a0, a1
44 ; RV64ZBB-NEXT: lui a1, 2048
45 ; RV64ZBB-NEXT: addiw a1, a1, 1
46 ; RV64ZBB-NEXT: or a0, a0, a1
47 ; RV64ZBB-NEXT: orc.b a0, a0
48 ; RV64ZBB-NEXT: sext.w a0, a0
51 ; RV64ZBP-LABEL: orcb32_knownbits:
53 ; RV64ZBP-NEXT: lui a1, 1044480
54 ; RV64ZBP-NEXT: and a0, a0, a1
55 ; RV64ZBP-NEXT: lui a1, 2048
56 ; RV64ZBP-NEXT: addiw a1, a1, 1
57 ; RV64ZBP-NEXT: or a0, a0, a1
58 ; RV64ZBP-NEXT: gorciw a0, a0, 7
60 %tmp = and i32 %a, 4278190080 ; 0xFF000000
61 %tmp2 = or i32 %tmp, 8388609 ; 0x800001
62 %tmp3 = call i32 @llvm.riscv.orc.b.i32(i32 %tmp2)
63 %tmp4 = and i32 %tmp3, 4278190080 ; 0xFF000000
64 %tmp5 = or i32 %tmp4, 16711935 ; 0xFF00FF
68 declare i64 @llvm.riscv.orc.b.i64(i64)
70 define i64 @orcb64(i64 %a) nounwind {
71 ; RV64ZBB-LABEL: orcb64:
73 ; RV64ZBB-NEXT: orc.b a0, a0
76 ; RV64ZBP-LABEL: orcb64:
78 ; RV64ZBP-NEXT: orc.b a0, a0
80 %tmp = call i64 @llvm.riscv.orc.b.i64(i64 %a)
84 ; Second and+or is redundant with the first, make sure we remove them.
85 define i64 @orcb64_knownbits(i64 %a) nounwind {
86 ; RV64ZBB-LABEL: orcb64_knownbits:
88 ; RV64ZBB-NEXT: lui a1, 65535
89 ; RV64ZBB-NEXT: slli a1, a1, 12
90 ; RV64ZBB-NEXT: and a0, a0, a1
91 ; RV64ZBB-NEXT: lui a1, 131073
92 ; RV64ZBB-NEXT: slli a1, a1, 13
93 ; RV64ZBB-NEXT: addi a1, a1, 1
94 ; RV64ZBB-NEXT: slli a1, a1, 20
95 ; RV64ZBB-NEXT: addi a1, a1, 8
96 ; RV64ZBB-NEXT: or a0, a0, a1
97 ; RV64ZBB-NEXT: orc.b a0, a0
100 ; RV64ZBP-LABEL: orcb64_knownbits:
102 ; RV64ZBP-NEXT: lui a1, 65535
103 ; RV64ZBP-NEXT: slli a1, a1, 12
104 ; RV64ZBP-NEXT: and a0, a0, a1
105 ; RV64ZBP-NEXT: lui a1, 131073
106 ; RV64ZBP-NEXT: slli a1, a1, 13
107 ; RV64ZBP-NEXT: addi a1, a1, 1
108 ; RV64ZBP-NEXT: slli a1, a1, 20
109 ; RV64ZBP-NEXT: addi a1, a1, 8
110 ; RV64ZBP-NEXT: or a0, a0, a1
111 ; RV64ZBP-NEXT: orc.b a0, a0
113 %tmp = and i64 %a, 1099494850560 ; 0x000000ffff000000
114 %tmp2 = or i64 %tmp, 4611721202800525320 ; 0x4000200000100008
115 %tmp3 = call i64 @llvm.riscv.orc.b.i64(i64 %tmp2)
116 %tmp4 = and i64 %tmp3, 1099494850560 ; 0x000000ffff000000
117 %tmp5 = or i64 %tmp4, 18374966855153418495 ; 0xff00ff0000ff00ff