[MemorySSA] Update phi map with replacement value.
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index 671d9e6..19f434f 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -713,8 +713,8 @@
           NewPhi->addIncoming(IncPhi, IncBB);
       }
     }
-    if (onlySingleValue(NewPhi)) {
-      MPhiMap[Phi] = nullptr;
+    if (auto *SingleAccess = onlySingleValue(NewPhi)) {
+      MPhiMap[Phi] = SingleAccess;
       removeMemoryAccess(NewPhi);
     }
   };