[llvm] [Utils] Avoid repeated hash lookups (NFC) (PR #130892)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 11 21:27:19 PDT 2025


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

None

>From e3bee797eed0f0b49e95bf5cee0b8f9ee6b19861 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 11 Mar 2025 09:13:11 -0700
Subject: [PATCH] [Utils] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
index 054b0ba2ba664..8470f0333d249 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
@@ -400,9 +400,10 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
       Last = New;
       for (ValueToValueMapTy::iterator VI = VMap.begin(), VE = VMap.end();
            VI != VE; ++VI) {
+        auto &LVM = LastValueMap[VI->first];
         PrevItValueMap[VI->second] =
-            const_cast<Value *>(It == 1 ? VI->first : LastValueMap[VI->first]);
-        LastValueMap[VI->first] = VI->second;
+            const_cast<Value *>(It == 1 ? VI->first : LVM);
+        LVM = VI->second;
       }
 
       NewBlocks.push_back(New);



More information about the llvm-commits mailing list