Skip to content

Commit 0cc74a8

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#124392)
1 parent 62bd217 commit 0cc74a8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/CodeGen/ModuloSchedule.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ void ModuloScheduleExpander::generateExistingPhis(
397397
// The Phi value from the loop body typically is defined in the loop, but
398398
// not always. So, we need to check if the value is defined in the loop.
399399
unsigned PhiOp2 = LoopVal;
400-
if (VRMap[LastStageNum].count(LoopVal))
401-
PhiOp2 = VRMap[LastStageNum][LoopVal];
400+
if (auto It = VRMap[LastStageNum].find(LoopVal);
401+
It != VRMap[LastStageNum].end())
402+
PhiOp2 = It->second;
402403

403404
int StageScheduled = Schedule.getStage(&*BBI);
404405
int LoopValStage = Schedule.getStage(MRI.getVRegDef(LoopVal));
@@ -1055,8 +1056,8 @@ void ModuloScheduleExpander::updateInstruction(MachineInstr *NewMI,
10551056
// Make an adjustment to get the last definition.
10561057
StageNum -= StageDiff;
10571058
}
1058-
if (VRMap[StageNum].count(reg))
1059-
MO.setReg(VRMap[StageNum][reg]);
1059+
if (auto It = VRMap[StageNum].find(reg); It != VRMap[StageNum].end())
1060+
MO.setReg(It->second);
10601061
}
10611062
}
10621063
}
@@ -1710,8 +1711,8 @@ void PeelingModuloScheduleExpander::moveStageBetweenBlocks(
17101711
for (MachineOperand &MO : I->uses()) {
17111712
if (!MO.isReg())
17121713
continue;
1713-
if (Remaps.count(MO.getReg()))
1714-
MO.setReg(Remaps[MO.getReg()]);
1714+
if (auto It = Remaps.find(MO.getReg()); It != Remaps.end())
1715+
MO.setReg(It->second);
17151716
else {
17161717
// If we are using a phi from the source block we need to add a new phi
17171718
// pointing to the old one.

0 commit comments

Comments
 (0)