[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #110203)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 08:03:32 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/110203
>From df53fda530512b9a4670a14a04d19b27afa5c4b6 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 26 Sep 2024 08:25:28 -0700
Subject: [PATCH 1/2] [CodeGen] Avoid repeated hash lookups (NFC)
---
llvm/lib/CodeGen/MachinePipeliner.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index cd8333931bb5f9..5475743905032c 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -1415,14 +1415,12 @@ class HighRegisterPressureDetector {
auto Reg = Use.RegUnit;
if (!TargetRegs.contains(Reg))
continue;
- auto Ite = LastUseMI.find(Reg);
- if (Ite == LastUseMI.end()) {
- LastUseMI[Reg] = MI;
- } else {
+ auto [Ite, Inserted] = LastUseMI.try_emplace(Reg, MI);
+ if (!Inserted) {
MachineInstr *Orig = Ite->second;
MachineInstr *New = MI;
if (InstrScore(Orig) < InstrScore(New))
- LastUseMI[Reg] = New;
+ Ite->second = New;
}
}
}
>From a1f05d515ffb9696b75c6183e0d78f113df46a2b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 27 Sep 2024 08:03:19 -0700
Subject: [PATCH 2/2] Trigger build
More information about the llvm-commits
mailing list