Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 18, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/112819.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp (+5-8)
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++;
   }
 }
 

@kazutakahirata kazutakahirata force-pushed the cleanup_001_repeated_hash_AMDGPU branch 5 times, most recently from 3d1ec00 to 52ad655 Compare October 20, 2024 20:40
@kazutakahirata kazutakahirata force-pushed the cleanup_001_repeated_hash_AMDGPU branch from 52ad655 to 5c17fec Compare October 21, 2024 14:07
@kazutakahirata kazutakahirata merged commit 766bd6f into llvm:main Oct 21, 2024
8 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_AMDGPU branch October 21, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants