@@ -902,14 +902,19 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
902902 for (Record *WR : ProcModel.WriteResDefs ) {
903903 if (!WR->isSubClassOf (" WriteRes" ))
904904 continue ;
905- if (AliasDef == WR->getValueAsDef (" WriteType" ) ||
906- SchedWrite.TheDef == WR-> getValueAsDef ( " WriteType " ) ) {
905+ Record *WRDef = WR->getValueAsDef (" WriteType" );
906+ if (AliasDef == WRDef || SchedWrite.TheDef == WRDef ) {
907907 if (ResDef) {
908908 PrintFatalError (WR->getLoc (), " Resources are defined for both "
909909 " SchedWrite and its alias on processor " +
910910 ProcModel.ModelName );
911911 }
912912 ResDef = WR;
913+ // If there is no AliasDef and we find a match, we can early exit since
914+ // there is no need to verify whether there are resources defined for both
915+ // SchedWrite and its alias.
916+ if (!AliasDef)
917+ break ;
913918 }
914919 }
915920 // TODO: If ProcModel has a base model (previous generation processor),
@@ -956,14 +961,19 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
956961 for (Record *RA : ProcModel.ReadAdvanceDefs ) {
957962 if (!RA->isSubClassOf (" ReadAdvance" ))
958963 continue ;
959- if (AliasDef == RA->getValueAsDef (" ReadType" ) ||
960- SchedRead.TheDef == RA-> getValueAsDef ( " ReadType " ) ) {
964+ Record *RADef = RA->getValueAsDef (" ReadType" );
965+ if (AliasDef == RADef || SchedRead.TheDef == RADef ) {
961966 if (ResDef) {
962967 PrintFatalError (RA->getLoc (), " Resources are defined for both "
963968 " SchedRead and its alias on processor " +
964969 ProcModel.ModelName );
965970 }
966971 ResDef = RA;
972+ // If there is no AliasDef and we find a match, we can early exit since
973+ // there is no need to verify whether there are resources defined for both
974+ // SchedRead and its alias.
975+ if (!AliasDef)
976+ break ;
967977 }
968978 }
969979 // TODO: If ProcModel has a base model (previous generation processor),
0 commit comments