[llvm] [SelectionDAG] Avoid repeated hash lookups (NFC) (PR #123697)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 23:00:25 PST 2025


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

None

>From 42782a58ce51361d00741a2a7dacace4b3658d15 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 20 Jan 2025 10:33:58 -0800
Subject: [PATCH] [SelectionDAG] Avoid repeated hash lookups (NFC)

---
 llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index a838003c34dfb0..987ea826f782e7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -871,10 +871,11 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
   for (const auto *Relocate : SI.GCRelocates) {
     Value *Derived = Relocate->getDerivedPtr();
     SDValue SD = getValue(Derived);
-    if (!LowerAsVReg.count(SD))
+    auto It = LowerAsVReg.find(SD);
+    if (It == LowerAsVReg.end())
       continue;
 
-    SDValue Relocated = SDValue(StatepointMCNode, LowerAsVReg[SD]);
+    SDValue Relocated = SDValue(StatepointMCNode, It->second);
 
     // Handle local relocate. Note that different relocates might
     // map to the same SDValue.



More information about the llvm-commits mailing list