Skip to content

Commit a2ad656

Browse files
authored
[RISCV] Add patterns for generating QC_CTO and QC_CLO (#144532)
These instructions count leading/trailing ones in the register. Currently these are only generated when we have `Zbb` enabled (along with `Xqcibm`) since it contains the `CTTZ/CTLZ` instructions.
1 parent a96a3f1 commit a2ad656

File tree

2 files changed

+963
-0
lines changed

2 files changed

+963
-0
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,11 @@ def : Pat<(i32 (and GPRNoX0:$rs, 1023)), (QC_EXTU GPRNoX0:$rs, 10, 0)>;
14521452
def : Pat<(i32 (and GPRNoX0:$rs, 2047)), (QC_EXTU GPRNoX0:$rs, 11, 0)>;
14531453
} // Predicates = [HasVendorXqcibm, IsRV32]
14541454

1455+
let Predicates = [HasVendorXqcibm, HasStdExtZbb, IsRV32] in {
1456+
def: Pat<(i32 (cttz (not (i32 GPR:$rs1)))), (QC_CTO GPR:$rs1)>;
1457+
def: Pat<(i32 (ctlz (not (i32 GPR:$rs1)))), (QC_CLO GPR:$rs1)>;
1458+
} // Predicates = [HasVendorXqcibm, HasStdExtZbb, IsRV32]
1459+
14551460
let Predicates = [HasVendorXqciint, IsRV32] in
14561461
def : Pat<(riscv_mileaveret_glue), (QC_C_MILEAVERET)>;
14571462

0 commit comments

Comments
 (0)