[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #110203)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 28 01:22:26 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/110203
>From e0498dc6572cf8143a66539254b2552da24a1d25 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] [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;
}
}
}
More information about the llvm-commits
mailing list