Skip to content

Commit 766bd6f

Browse files
[AMDGPU] Avoid repeated map lookups (NFC) (#112819)
1 parent 8ae39c8 commit 766bd6f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -878,14 +878,11 @@ void SIScheduleBlockCreator::colorAccordingToReservedDependencies() {
878878
SUColors.first = CurrentTopDownReservedDependencyColoring[SU.NodeNum];
879879
SUColors.second = CurrentBottomUpReservedDependencyColoring[SU.NodeNum];
880880

881-
std::map<std::pair<unsigned, unsigned>, unsigned>::iterator Pos =
882-
ColorCombinations.find(SUColors);
883-
if (Pos != ColorCombinations.end()) {
884-
CurrentColoring[SU.NodeNum] = Pos->second;
885-
} else {
886-
CurrentColoring[SU.NodeNum] = NextNonReservedID;
887-
ColorCombinations[SUColors] = NextNonReservedID++;
888-
}
881+
auto [Pos, Inserted] =
882+
ColorCombinations.try_emplace(SUColors, NextNonReservedID);
883+
CurrentColoring[SU.NodeNum] = Pos->second;
884+
if (Inserted)
885+
NextNonReservedID++;
889886
}
890887
}
891888

0 commit comments

Comments
 (0)