[llvm] [AMDGPU] Avoid repeated map lookups (NFC) (PR #112819)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 20:23:48 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112819
None
>From 28f2f0e9fc8a991b2f40f5b3a73d32d42acbd7a2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 17 Oct 2024 07:54:04 -0700
Subject: [PATCH] [AMDGPU] Avoid repeated map lookups (NFC)
---
llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
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