[llvm] c675a58 - [TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and FindReadAdvance (#92202)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 06:48:46 PDT 2024
Author: Michael Maitland
Date: 2024-05-16T09:48:42-04:00
New Revision: c675a58edec6d1a876a0d0e7d261f74764855b38
URL: https://github.com/llvm/llvm-project/commit/c675a58edec6d1a876a0d0e7d261f74764855b38
DIFF: https://github.com/llvm/llvm-project/commit/c675a58edec6d1a876a0d0e7d261f74764855b38.diff
LOG: [TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and FindReadAdvance (#92202)
This gives us a 30% speed improvement in our downstream.
Added:
Modified:
llvm/utils/TableGen/SubtargetEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index 9e32d2de19b2c..323470940fec5 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -902,14 +902,19 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
for (Record *WR : ProcModel.WriteResDefs) {
if (!WR->isSubClassOf("WriteRes"))
continue;
- if (AliasDef == WR->getValueAsDef("WriteType") ||
- SchedWrite.TheDef == WR->getValueAsDef("WriteType")) {
+ Record *WRDef = WR->getValueAsDef("WriteType");
+ if (AliasDef == WRDef || SchedWrite.TheDef == WRDef) {
if (ResDef) {
PrintFatalError(WR->getLoc(), "Resources are defined for both "
"SchedWrite and its alias on processor " +
ProcModel.ModelName);
}
ResDef = WR;
+ // If there is no AliasDef and we find a match, we can early exit since
+ // there is no need to verify whether there are resources defined for both
+ // SchedWrite and its alias.
+ if (!AliasDef)
+ break;
}
}
// TODO: If ProcModel has a base model (previous generation processor),
@@ -956,14 +961,19 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
for (Record *RA : ProcModel.ReadAdvanceDefs) {
if (!RA->isSubClassOf("ReadAdvance"))
continue;
- if (AliasDef == RA->getValueAsDef("ReadType") ||
- SchedRead.TheDef == RA->getValueAsDef("ReadType")) {
+ Record *RADef = RA->getValueAsDef("ReadType");
+ if (AliasDef == RADef || SchedRead.TheDef == RADef) {
if (ResDef) {
PrintFatalError(RA->getLoc(), "Resources are defined for both "
"SchedRead and its alias on processor " +
ProcModel.ModelName);
}
ResDef = RA;
+ // If there is no AliasDef and we find a match, we can early exit since
+ // there is no need to verify whether there are resources defined for both
+ // SchedRead and its alias.
+ if (!AliasDef)
+ break;
}
}
// TODO: If ProcModel has a base model (previous generation processor),
More information about the llvm-commits
mailing list