diff options
| author | Kazu Hirata <kazu@google.com> | 2025-03-24 22:41:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-24 22:41:27 -0700 |
| commit | 75210df5a2dd6bd9b6fb9d8fbaea27f748c4c41e (patch) | |
| tree | 52b44fbf877df94590fbd99a05a5aa0eaab357bc | |
| parent | cca0f8113e2f9a1bd662c62dd3ff7e1fa197e6b5 (diff) | |
[AMDGPU] Avoid repeated map lookups (NFC) (#132877)
| -rw-r--r-- | llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp index b3fa65512e4c..2bbbbf4db02d 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp @@ -806,15 +806,11 @@ void SIScheduleBlockCreator::colorComputeReservedDependencies() { CurrentTopDownReservedDependencyColoring[SU->NodeNum] = *SUColors.begin(); else { - std::map<std::set<unsigned>, unsigned>::iterator Pos = - ColorCombinations.find(SUColors); - if (Pos != ColorCombinations.end()) { - CurrentTopDownReservedDependencyColoring[SU->NodeNum] = Pos->second; - } else { - CurrentTopDownReservedDependencyColoring[SU->NodeNum] = - NextNonReservedID; - ColorCombinations[SUColors] = NextNonReservedID++; - } + auto [Pos, Inserted] = + ColorCombinations.try_emplace(SUColors, NextNonReservedID); + if (Inserted) + ++NextNonReservedID; + CurrentTopDownReservedDependencyColoring[SU->NodeNum] = Pos->second; } } @@ -1176,14 +1172,15 @@ void SIScheduleBlockCreator::createBlocksForVariant(SISchedulerBlockCreatorVaria for (unsigned i = 0, e = DAGSize; i != e; ++i) { SUnit *SU = &DAG->SUnits[i]; unsigned Color = CurrentColoring[SU->NodeNum]; - if (RealID.find(Color) == RealID.end()) { + auto [It, Inserted] = RealID.try_emplace(Color); + if (Inserted) { int ID = CurrentBlocks.size(); BlockPtrs.push_back(std::make_unique<SIScheduleBlock>(DAG, this, ID)); CurrentBlocks.push_back(BlockPtrs.rbegin()->get()); - RealID[Color] = ID; + It->second = ID; } - CurrentBlocks[RealID[Color]]->addUnit(SU); - Node2CurrentBlock[SU->NodeNum] = RealID[Color]; + CurrentBlocks[It->second]->addUnit(SU); + Node2CurrentBlock[SU->NodeNum] = It->second; } // Build dependencies between blocks. |
