Skip to content

Commit 9235b8d

Browse files
[TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources
This gives us a 26% speed improvement in our downstream.
1 parent 99fad7e commit 9235b8d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

llvm/utils/TableGen/SubtargetEmitter.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -904,14 +904,17 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
904904
continue;
905905
if (AliasDef == WR->getValueAsDef("WriteType") ||
906906
SchedWrite.TheDef == WR->getValueAsDef("WriteType")) {
907-
if (ResDef) {
908-
PrintFatalError(WR->getLoc(), "Resources are defined for both "
909-
"SchedWrite and its alias on processor " +
910-
ProcModel.ModelName);
911-
}
912907
ResDef = WR;
908+
break;
913909
}
914910
}
911+
912+
if (ResDef && AliasDef) {
913+
PrintFatalError(ResDef->getLoc(), "Resources are defined for both "
914+
"SchedWrite and its alias on processor " +
915+
ProcModel.ModelName);
916+
}
917+
915918
// TODO: If ProcModel has a base model (previous generation processor),
916919
// then call FindWriteResources recursively with that model here.
917920
if (!ResDef) {
@@ -958,14 +961,16 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
958961
continue;
959962
if (AliasDef == RA->getValueAsDef("ReadType") ||
960963
SchedRead.TheDef == RA->getValueAsDef("ReadType")) {
961-
if (ResDef) {
962-
PrintFatalError(RA->getLoc(), "Resources are defined for both "
963-
"SchedRead and its alias on processor " +
964-
ProcModel.ModelName);
965-
}
966964
ResDef = RA;
965+
break;
967966
}
968967
}
968+
if (ResDef && AliasDef) {
969+
PrintFatalError(ResDef->getLoc(), "Resources are defined for both "
970+
"SchedRead and its alias on processor " +
971+
ProcModel.ModelName);
972+
}
973+
969974
// TODO: If ProcModel has a base model (previous generation processor),
970975
// then call FindReadAdvance recursively with that model here.
971976
if (!ResDef && SchedRead.TheDef->getName() != "ReadDefault") {

0 commit comments

Comments
 (0)