diff --git a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp index 7c7e0204b1764..77b4f25021c75 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp @@ -878,14 +878,11 @@ void SIScheduleBlockCreator::colorAccordingToReservedDependencies() { SUColors.first = CurrentTopDownReservedDependencyColoring[SU.NodeNum]; SUColors.second = CurrentBottomUpReservedDependencyColoring[SU.NodeNum]; - std::map, unsigned>::iterator Pos = - ColorCombinations.find(SUColors); - if (Pos != ColorCombinations.end()) { - CurrentColoring[SU.NodeNum] = Pos->second; - } else { - CurrentColoring[SU.NodeNum] = NextNonReservedID; - ColorCombinations[SUColors] = NextNonReservedID++; - } + auto [Pos, Inserted] = + ColorCombinations.try_emplace(SUColors, NextNonReservedID); + CurrentColoring[SU.NodeNum] = Pos->second; + if (Inserted) + NextNonReservedID++; } }