Skip to content

Commit 616f277

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#130237)
1 parent 17aac7c commit 616f277

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

llvm/lib/CodeGen/ModuloSchedule.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,12 @@ void ModuloScheduleExpander::generateExistingPhis(
464464
InstOp1 = MRI.getVRegDef(PhiOp1);
465465
int PhiOpStage = Schedule.getStage(InstOp1);
466466
int StageAdj = (PhiOpStage != -1 ? PhiStage - PhiOpStage : 0);
467-
if (PhiOpStage != -1 && PrologStage - StageAdj >= Indirects + np &&
468-
VRMap[PrologStage - StageAdj - Indirects - np].count(PhiOp1)) {
469-
PhiOp1 = VRMap[PrologStage - StageAdj - Indirects - np][PhiOp1];
470-
break;
467+
if (PhiOpStage != -1 && PrologStage - StageAdj >= Indirects + np) {
468+
auto &M = VRMap[PrologStage - StageAdj - Indirects - np];
469+
if (auto It = M.find(PhiOp1); It != M.end()) {
470+
PhiOp1 = It->second;
471+
break;
472+
}
471473
}
472474
++Indirects;
473475
}
@@ -597,8 +599,11 @@ void ModuloScheduleExpander::generateExistingPhis(
597599

598600
// Check if we need to rename a Phi that has been eliminated due to
599601
// scheduling.
600-
if (NumStages == 0 && IsLast && VRMap[CurStageNum].count(LoopVal))
601-
replaceRegUsesAfterLoop(Def, VRMap[CurStageNum][LoopVal], BB, MRI, LIS);
602+
if (NumStages == 0 && IsLast) {
603+
auto It = VRMap[CurStageNum].find(LoopVal);
604+
if (It != VRMap[CurStageNum].end())
605+
replaceRegUsesAfterLoop(Def, It->second, BB, MRI, LIS);
606+
}
602607
}
603608
}
604609

0 commit comments

Comments
 (0)