[CodeGen] Avoid repeated map lookups (NFC) (#127025)

diff --git a/llvm/lib/CodeGen/LiveStacks.cpp b/llvm/lib/CodeGen/LiveStacks.cpp
index d615caf..c07d985 100644
--- a/llvm/lib/CodeGen/LiveStacks.cpp
+++ b/llvm/lib/CodeGen/LiveStacks.cpp
@@ -62,8 +62,8 @@
     S2RCMap.insert(std::make_pair(Slot, RC));
   } else {
     // Use the largest common subclass register class.
-    const TargetRegisterClass *OldRC = S2RCMap[Slot];
-    S2RCMap[Slot] = TRI->getCommonSubClass(OldRC, RC);
+    const TargetRegisterClass *&OldRC = S2RCMap[Slot];
+    OldRC = TRI->getCommonSubClass(OldRC, RC);
   }
   return I->second;
 }