[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #125160)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 20:16:32 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/125160
None
>From 157cb995fa6eb891e4af99e13d8cba42bf6416c3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 30 Jan 2025 18:04:38 -0800
Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC)
---
llvm/lib/CodeGen/WindowScheduler.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/CodeGen/WindowScheduler.cpp b/llvm/lib/CodeGen/WindowScheduler.cpp
index f1658e36ae1e92b..e7fc0d9a3d2548f 100644
--- a/llvm/lib/CodeGen/WindowScheduler.cpp
+++ b/llvm/lib/CodeGen/WindowScheduler.cpp
@@ -356,8 +356,8 @@ void WindowScheduler::generateTripleMBB() {
// ==================================
// < Terminators >
// ==================================
- if (DefPairs.count(NewUse))
- NewUse = DefPairs[NewUse];
+ if (auto It = DefPairs.find(NewUse); It != DefPairs.end())
+ NewUse = It->second;
NewMI->substituteRegister(DefRegPair.first, NewUse, 0, *TRI);
}
// DefPairs is updated at last.
@@ -581,9 +581,10 @@ DenseMap<MachineInstr *, int> WindowScheduler::getIssueOrder(unsigned Offset,
DenseMap<MachineInstr *, int> IssueOrder;
int Id = 0;
for (int Cycle = 0; Cycle < (int)II; ++Cycle) {
- if (!CycleToMIs.count(Cycle))
+ auto It = CycleToMIs.find(Cycle);
+ if (It == CycleToMIs.end())
continue;
- for (auto *MI : CycleToMIs[Cycle])
+ for (auto *MI : It->second)
IssueOrder[MI] = Id++;
}
return IssueOrder;
More information about the llvm-commits
mailing list