From 157cb995fa6eb891e4af99e13d8cba42bf6416c3 Mon Sep 17 00:00:00 2001 From: Kazu Hirata 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 f1658e36ae1e9..e7fc0d9a3d254 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 WindowScheduler::getIssueOrder(unsigned Offset, DenseMap 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;