[llvm] 766bd6f - [AMDGPU] Avoid repeated map lookups (NFC) (#112819)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 10:35:56 PDT 2024


Author: Kazu Hirata
Date: 2024-10-21T10:35:53-07:00
New Revision: 766bd6f4d05a4b52892be4f1b740e67053a22ee6

URL: https://github.com/llvm/llvm-project/commit/766bd6f4d05a4b52892be4f1b740e67053a22ee6
DIFF: https://github.com/llvm/llvm-project/commit/766bd6f4d05a4b52892be4f1b740e67053a22ee6.diff

LOG: [AMDGPU] Avoid repeated map lookups (NFC) (#112819)

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp
index 7c7e0204b17644..77b4f25021c75d 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<std::pair<unsigned, unsigned>, 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++;
   }
 }
 


        


More information about the llvm-commits mailing list