diff options
author | Kazu Hirata <kazu@google.com> | 2025-01-25 01:17:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-25 01:17:22 -0800 |
commit | 0cc74a8941884d56a4718c28cc5b8ef8dbe17047 (patch) | |
tree | b5b944640463f2db2cd5f2909983236fa0157a90 /llvm/lib/CodeGen/ModuloSchedule.cpp | |
parent | 62bd217b5a1cf6b231b2413b5522533986d4e5df (diff) | |
download | llvm-0cc74a8941884d56a4718c28cc5b8ef8dbe17047.zip llvm-0cc74a8941884d56a4718c28cc5b8ef8dbe17047.tar.gz llvm-0cc74a8941884d56a4718c28cc5b8ef8dbe17047.tar.bz2 |
[CodeGen] Avoid repeated hash lookups (NFC) (#124392)
Diffstat (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ModuloSchedule.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp index d99b6ac..f9fe812 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. |