Skip to content

Commit

Permalink
[RISCV] Replace i64:$r in tablegen patterns with GPR:$r. NFC
Browse files Browse the repository at this point in the history
It's much more common to use a register class rather than a type.

Add an additional i64 cast to the patterns where needed to avoid
increasing isel table size.
  • Loading branch information
topperc committed Dec 20, 2022
1 parent b6e344c commit 36179ec
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions llvm/lib/Target/RISCV/RISCVInstrInfoXVentana.td
Expand Up @@ -29,32 +29,32 @@ def VT_MASKCN : VTMaskedMove<0b111, "vt.maskcn">,
Sched<[WriteIALU, ReadIALU, ReadIALU]>;

multiclass XVentanaCondops_pats<SDPatternOperator Op, RVInst MI> {
def: Pat<(select i64:$rc, (Op i64:$rs1, i64:$rs2), i64:$rs1),
(MI $rs1, (VT_MASKC $rs2, $rc))>;
def: Pat<(select i64:$rc, i64:$rs1, (Op i64:$rs1, i64:$rs2)),
(MI $rs1, (VT_MASKCN $rs2, $rc))>;
def : Pat<(i64 (select GPR:$rc, (Op GPR:$rs1, GPR:$rs2), GPR:$rs1)),
(MI $rs1, (VT_MASKC $rs2, $rc))>;
def : Pat<(i64 (select GPR:$rc, GPR:$rs1, (Op GPR:$rs1, GPR:$rs2))),
(MI $rs1, (VT_MASKCN $rs2, $rc))>;
}

let Predicates = [IsRV64, HasVendorXVentanaCondOps] in {
// Directly use MASKC/MASKCN in case of any of the operands being 0.
def: Pat<(select i64:$rc, i64:$rs1, (i64 0)),
(VT_MASKC $rs1, $rc)>;
def: Pat<(select i64:$rc, (i64 0), i64:$rs1),
(VT_MASKCN $rs1, $rc)>;
def : Pat<(select GPR:$rc, GPR:$rs1, (i64 0)),
(VT_MASKC $rs1, $rc)>;
def : Pat<(select GPR:$rc, (i64 0), GPR:$rs1),
(VT_MASKCN $rs1, $rc)>;

// Conditional operations patterns.
defm: XVentanaCondops_pats<add, ADD>;
defm: XVentanaCondops_pats<sub, SUB>;
defm: XVentanaCondops_pats<or, OR>;
defm: XVentanaCondops_pats<xor, XOR>;
defm : XVentanaCondops_pats<add, ADD>;
defm : XVentanaCondops_pats<sub, SUB>;
defm : XVentanaCondops_pats<or, OR>;
defm : XVentanaCondops_pats<xor, XOR>;

// Conditional AND operation patterns.
def: Pat<(select i64:$rc, (and i64:$rs1, i64:$rs2), i64:$rs1),
(OR (AND $rs1, $rs2), (VT_MASKCN $rs1, $rc))>;
def: Pat<(select i64:$rc, i64:$rs1, (and i64:$rs1, i64:$rs2)),
(OR (AND $rs1, $rs2), (VT_MASKC $rs1, $rc))>;
def : Pat<(i64 (select GPR:$rc, (and GPR:$rs1, GPR:$rs2), GPR:$rs1)),
(OR (AND $rs1, $rs2), (VT_MASKCN $rs1, $rc))>;
def : Pat<(i64 (select GPR:$rc, GPR:$rs1, (and GPR:$rs1, GPR:$rs2))),
(OR (AND $rs1, $rs2), (VT_MASKC $rs1, $rc))>;

// Basic select pattern that selects between 2 registers.
def: Pat<(select i64:$rc, i64:$rs1, i64:$rs2),
(OR (VT_MASKC $rs1, $rc), (VT_MASKCN $rs2, $rc))>;
def : Pat<(i64 (select GPR:$rc, GPR:$rs1, GPR:$rs2)),
(OR (VT_MASKC $rs1, $rc), (VT_MASKCN $rs2, $rc))>;
} // Predicates = [IsRV64, HasVendorXVentanaCondOps]

0 comments on commit 36179ec

Please sign in to comment.