Skip to content

Commit 390fbe6

Browse files
authored
[RISCV] Use Predicates instead of Added Complexity to prefer QC_SELECTEQI over QC_MVEQI. NFC (#148312)
IMHO AddedComplexity should be used as a last resort. We should use other mechanism like Predicates and PatFrag predicates to give priority.
1 parent d1e3ab9 commit 390fbe6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,8 @@ def HasVendorXqcics
14871487
: Predicate<"Subtarget->hasVendorXqcics()">,
14881488
AssemblerPredicate<(all_of FeatureVendorXqcics),
14891489
"'Xqcics' (Qualcomm uC Conditional Select Extension)">;
1490+
def NoVendorXqcics
1491+
: Predicate<"!Subtarget->hasVendorXqcics()">;
14901492

14911493
def FeatureVendorXqcicsr
14921494
: RISCVExperimentalExtension<0, 4, "Qualcomm uC CSR Extension">;

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,12 +1484,16 @@ def : QCIMVCCPat <SETNE, QC_MVNE>;
14841484
def : QCIMVCCPat <SETLT, QC_MVLT>;
14851485
def : QCIMVCCPat <SETULT, QC_MVLTU>;
14861486

1487-
def : QCIMVCCIPat <SETEQ, QC_MVEQI, simm5>;
1488-
def : QCIMVCCIPat <SETNE, QC_MVNEI, simm5>;
14891487
def : QCIMVCCIPat <SETLT, QC_MVLTI, simm5>;
14901488
def : QCIMVCCIPat <SETULT, QC_MVLTUI, uimm5>;
14911489
}
14921490

1491+
// Prioritize Xqcics over these patterns.
1492+
let Predicates = [HasVendorXqcicm, NoVendorXqcics, IsRV32] in {
1493+
def : QCIMVCCIPat <SETEQ, QC_MVEQI, simm5>;
1494+
def : QCIMVCCIPat <SETNE, QC_MVNEI, simm5>;
1495+
}
1496+
14931497
let Predicates = [HasVendorXqcics, IsRV32] in {
14941498
def : Pat<(select (i32 GPRNoX0:$rd), (i32 GPRNoX0:$rs2),(i32 GPRNoX0:$rs3)),
14951499
(QC_SELECTNEI GPRNoX0:$rd, (i32 0), GPRNoX0:$rs2, GPRNoX0:$rs3)>;
@@ -1498,12 +1502,8 @@ def : Pat<(select (i32 GPRNoX0:$rd), (i32 GPRNoX0:$rs2), simm5:$simm2),
14981502
def : Pat<(select (i32 GPRNoX0:$rd), simm5:$simm2,(i32 GPRNoX0:$rs2)),
14991503
(QC_SELECTIEQI GPRNoX0:$rd, (i32 0), GPRNoX0:$rs2, simm5:$simm2)>;
15001504

1501-
// Below AddedComplexity is added to prefer these conditional select instructions over
1502-
// conditional move instructions
1503-
let AddedComplexity = 1 in {
15041505
def : QCISELECTCCIPat <SETEQ, QC_SELECTEQI>;
15051506
def : QCISELECTCCIPat <SETNE, QC_SELECTNEI>;
1506-
}
15071507

15081508
def : QCISELECTICCIPat <SETEQ, QC_SELECTIEQI>;
15091509
def : QCISELECTICCIPat <SETNE, QC_SELECTINEI>;

0 commit comments

Comments
 (0)