[llvm] 312c1cf - [CodeGen] Avoid repeated hash lookups (NFC) (#110203)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 28 10:04:47 PDT 2024
Author: Kazu Hirata
Date: 2024-09-28T10:04:44-07:00
New Revision: 312c1cfbd165f56c0d092933b7a829f054afe323
URL: https://github.com/llvm/llvm-project/commit/312c1cfbd165f56c0d092933b7a829f054afe323
DIFF: https://github.com/llvm/llvm-project/commit/312c1cfbd165f56c0d092933b7a829f054afe323.diff
LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#110203)
Added:
Modified:
llvm/lib/CodeGen/MachinePipeliner.cpp
Removed:
################################################################################
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