@@ -902,17 +902,20 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
902
902
for (Record *WR : ProcModel.WriteResDefs ) {
903
903
if (!WR->isSubClassOf (" WriteRes" ))
904
904
continue ;
905
- if (AliasDef == WR->getValueAsDef (" WriteType" ) ||
906
- SchedWrite.TheDef == WR->getValueAsDef (" WriteType" )) {
905
+ // If there is no AliasDef and we find a match, we can early exit since
906
+ // there is no need to verify whether there are resources defined for both
907
+ // SchedWrite and its alias.
908
+ if (!AliasDef && SchedWrite.TheDef == WR->getValueAsDef (" WriteType" )) {
907
909
ResDef = WR;
908
910
break ;
909
- }
910
- }
911
-
912
- if (ResDef && AliasDef) {
913
- PrintFatalError (ResDef->getLoc (), " Resources are defined for both "
911
+ } else if (AliasDef == WR->getValueAsDef (" WriteType" )) {
912
+ if (ResDef) {
913
+ PrintFatalError (WR->getLoc (), " Resources are defined for both "
914
914
" SchedWrite and its alias on processor " +
915
915
ProcModel.ModelName );
916
+ }
917
+ ResDef = WR;
918
+ }
916
919
}
917
920
918
921
// TODO: If ProcModel has a base model (previous generation processor),
@@ -959,16 +962,20 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
959
962
for (Record *RA : ProcModel.ReadAdvanceDefs ) {
960
963
if (!RA->isSubClassOf (" ReadAdvance" ))
961
964
continue ;
962
- if (AliasDef == RA->getValueAsDef (" ReadType" ) ||
963
- SchedRead.TheDef == RA->getValueAsDef (" ReadType" )) {
964
- ResDef = RA;
965
+ // If there is no AliasDef and we find a match, we can early exit since
966
+ // there is no need to verify whether there are resources defined for both
967
+ // SchedWrite and its alias.
968
+ if (!AliasDef && AliasDef == RA->getValueAsDef (" ReadType" )) {
969
+ ResDef = WR;
965
970
break ;
966
- }
967
- }
968
- if (ResDef && AliasDef) {
969
- PrintFatalError (ResDef->getLoc (), " Resources are defined for both "
970
- " SchedRead and its alias on processor " +
971
+ } else if (SchedRead.TheDef == RA->getValueAsDef (" ReadType" )) {
972
+ if (ResDef) {
973
+ PrintFatalError (WR->getLoc (), " Resources are defined for both "
974
+ " SchedWrite and its alias on processor " +
971
975
ProcModel.ModelName );
976
+ }
977
+ ResDef = RA;
978
+ }
972
979
}
973
980
974
981
// TODO: If ProcModel has a base model (previous generation processor),
0 commit comments