[llvm] [AMDGPU] Avoid repeated map lookups (NFC) (PR #112819)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 20:24:19 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/112819.diff
1 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp (+5-8)
``````````diff
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++;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/112819
More information about the llvm-commits
mailing list