[llvm] 40c65e8 - [CodeGen] Avoid repeated hash lookups (NFC) (#129821)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 4 22:17:03 PST 2025


Author: Kazu Hirata
Date: 2025-03-04T22:17:00-08:00
New Revision: 40c65e858957eee4bc563f432beb0e08fe383b7c

URL: https://github.com/llvm/llvm-project/commit/40c65e858957eee4bc563f432beb0e08fe383b7c
DIFF: https://github.com/llvm/llvm-project/commit/40c65e858957eee4bc563f432beb0e08fe383b7c.diff

LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#129821)

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineScheduler.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 0eecceea3dd1e..5086ee8829b25 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -2032,10 +2032,11 @@ void BaseMemOpClusterMutation::clusterNeighboringMemOps(
     unsigned ClusterLength = 2;
     unsigned CurrentClusterBytes = MemOpa.Width.getValue().getKnownMinValue() +
                                    MemOpb.Width.getValue().getKnownMinValue();
-    if (SUnit2ClusterInfo.count(MemOpa.SU->NodeNum)) {
-      ClusterLength = SUnit2ClusterInfo[MemOpa.SU->NodeNum].first + 1;
-      CurrentClusterBytes = SUnit2ClusterInfo[MemOpa.SU->NodeNum].second +
-                            MemOpb.Width.getValue().getKnownMinValue();
+    auto It = SUnit2ClusterInfo.find(MemOpa.SU->NodeNum);
+    if (It != SUnit2ClusterInfo.end()) {
+      const auto &[Len, Bytes] = It->second;
+      ClusterLength = Len + 1;
+      CurrentClusterBytes = Bytes + MemOpb.Width.getValue().getKnownMinValue();
     }
 
     if (!TII->shouldClusterMemOps(MemOpa.BaseOps, MemOpa.Offset,


        


More information about the llvm-commits mailing list