[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #122861)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 21:44:36 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/122861

None

>From d2c324417a35869e25903adc52c438f57fb9a07a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 13 Jan 2025 21:37:58 -0800
Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC)

---
 llvm/include/llvm/CodeGen/ModuloSchedule.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/ModuloSchedule.h b/llvm/include/llvm/CodeGen/ModuloSchedule.h
index e9f0f089adfef8..64598ce449a44d 100644
--- a/llvm/include/llvm/CodeGen/ModuloSchedule.h
+++ b/llvm/include/llvm/CodeGen/ModuloSchedule.h
@@ -359,8 +359,8 @@ class PeelingModuloScheduleExpander {
   MachineBasicBlock *CreateLCSSAExitingBlock();
   /// Helper to get the stage of an instruction in the schedule.
   unsigned getStage(MachineInstr *MI) {
-    if (CanonicalMIs.count(MI))
-      MI = CanonicalMIs[MI];
+    if (auto It = CanonicalMIs.find(MI); It != CanonicalMIs.end())
+      MI = It->second;
     return Schedule.getStage(MI);
   }
   /// Helper function to find the right canonical register for a phi instruction



More information about the llvm-commits mailing list