- Notifications
You must be signed in to change notification settings - Fork14.5k
[RISCV] Use Predicates instead of Added Complexity to prefer QC_SELECTEQI over QC_MVEQI. NFC#148312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
…TEQI over QC_MVEQI. NFCIMHO AddedComplexity should be used as a last resort. We shoulduse other mechanism like Predicates and PatFrag predicates to givepriority.
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesIMHO AddedComplexity should be used as a last resort. We should use other mechanism like Predicates and PatFrag predicates to give priority. Full diff:https://github.com/llvm/llvm-project/pull/148312.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.tdindex bf58226e0bd39..f74f1e06d66a2 100644--- a/llvm/lib/Target/RISCV/RISCVFeatures.td+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td@@ -1487,6 +1487,8 @@ def HasVendorXqcics : Predicate<"Subtarget->hasVendorXqcics()">, AssemblerPredicate<(all_of FeatureVendorXqcics), "'Xqcics' (Qualcomm uC Conditional Select Extension)">;+def NoVendorXqcics+ : Predicate<"!Subtarget->hasVendorXqcics()">; def FeatureVendorXqcicsr : RISCVExperimentalExtension<0, 4, "Qualcomm uC CSR Extension">;diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.tdindex 9e3eb1c03fb37..afb11998e9277 100644--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td@@ -1484,12 +1484,16 @@ def : QCIMVCCPat <SETNE, QC_MVNE>; def : QCIMVCCPat <SETLT, QC_MVLT>; def : QCIMVCCPat <SETULT, QC_MVLTU>;-def : QCIMVCCIPat <SETEQ, QC_MVEQI, simm5>;-def : QCIMVCCIPat <SETNE, QC_MVNEI, simm5>; def : QCIMVCCIPat <SETLT, QC_MVLTI, simm5>; def : QCIMVCCIPat <SETULT, QC_MVLTUI, uimm5>; }+// Prioritize Xqcics over these patterns.+let Predicates = [HasVendorXqcicm, NoVendorXqcics, IsRV32] in {+def : QCIMVCCIPat <SETEQ, QC_MVEQI, simm5>;+def : QCIMVCCIPat <SETNE, QC_MVNEI, simm5>;+}+ let Predicates = [HasVendorXqcics, IsRV32] in { def : Pat<(select (XLenVT GPRNoX0:$rd), (XLenVT GPRNoX0:$rs2),(XLenVT GPRNoX0:$rs3)), (QC_SELECTNEI GPRNoX0:$rd, (XLenVT 0), GPRNoX0:$rs2, GPRNoX0:$rs3)>;@@ -1498,12 +1502,8 @@ def : Pat<(select (XLenVT GPRNoX0:$rd), (XLenVT GPRNoX0:$rs2), simm5:$simm2), def : Pat<(select (XLenVT GPRNoX0:$rd), simm5:$simm2,(XLenVT GPRNoX0:$rs2)), (QC_SELECTIEQI GPRNoX0:$rd, (XLenVT 0), GPRNoX0:$rs2, simm5:$simm2)>;-// Below AddedComplexity is added to prefer these conditional select instructions over-// conditional move instructions-let AddedComplexity = 1 in { def : QCISELECTCCIPat <SETEQ, QC_SELECTEQI>; def : QCISELECTCCIPat <SETNE, QC_SELECTNEI>;-} def : QCISELECTICCIPat <SETEQ, QC_SELECTIEQI>; def : QCISELECTICCIPat <SETNE, QC_SELECTINEI>; |
lenary approved these changesJul 12, 2025
390fbe6
intollvm:main 11 checks passed
Uh oh!
There was an error while loading.Please reload this page.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IMHO AddedComplexity should be used as a last resort. We should use other mechanism like Predicates and PatFrag predicates to give priority.