[llvm] 0cc74a8 - [CodeGen] Avoid repeated hash lookups (NFC) (#124392)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 25 01:17:25 PST 2025
Author: Kazu Hirata
Date: 2025-01-25T01:17:22-08:00
New Revision: 0cc74a8941884d56a4718c28cc5b8ef8dbe17047
URL: https://github.com/llvm/llvm-project/commit/0cc74a8941884d56a4718c28cc5b8ef8dbe17047
DIFF: https://github.com/llvm/llvm-project/commit/0cc74a8941884d56a4718c28cc5b8ef8dbe17047.diff
LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#124392)
Added:
Modified:
llvm/lib/CodeGen/ModuloSchedule.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index d99b6ace01000d..f9fe812f7e65ca 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -397,8 +397,9 @@ void ModuloScheduleExpander::generateExistingPhis(
// The Phi value from the loop body typically is defined in the loop, but
// not always. So, we need to check if the value is defined in the loop.
unsigned PhiOp2 = LoopVal;
- if (VRMap[LastStageNum].count(LoopVal))
- PhiOp2 = VRMap[LastStageNum][LoopVal];
+ if (auto It = VRMap[LastStageNum].find(LoopVal);
+ It != VRMap[LastStageNum].end())
+ PhiOp2 = It->second;
int StageScheduled = Schedule.getStage(&*BBI);
int LoopValStage = Schedule.getStage(MRI.getVRegDef(LoopVal));
@@ -1055,8 +1056,8 @@ void ModuloScheduleExpander::updateInstruction(MachineInstr *NewMI,
// Make an adjustment to get the last definition.
StageNum -= StageDiff;
}
- if (VRMap[StageNum].count(reg))
- MO.setReg(VRMap[StageNum][reg]);
+ if (auto It = VRMap[StageNum].find(reg); It != VRMap[StageNum].end())
+ MO.setReg(It->second);
}
}
}
@@ -1710,8 +1711,8 @@ void PeelingModuloScheduleExpander::moveStageBetweenBlocks(
for (MachineOperand &MO : I->uses()) {
if (!MO.isReg())
continue;
- if (Remaps.count(MO.getReg()))
- MO.setReg(Remaps[MO.getReg()]);
+ if (auto It = Remaps.find(MO.getReg()); It != Remaps.end())
+ MO.setReg(It->second);
else {
// If we are using a phi from the source block we need to add a new phi
// pointing to the old one.
More information about the llvm-commits
mailing list