[LVI] Manually hoist computation from loop

Minor compile time win.  Not known to be a hot spot, just something I noticed while reading.

llvm-svn: 290759
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index e51e821..cd1f250 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -525,23 +525,28 @@
     // Skip blocks only accessible through NewSucc.
     if (ToUpdate == NewSucc) continue;
 
+    // If a value was marked overdefined in OldSucc, and is here too...
+    auto OI = OverDefinedCache.find(ToUpdate);
+    if (OI == OverDefinedCache.end())
+      continue;
+    SmallPtrSetImpl<Value *> &ValueSet = OI->second;
+
     bool changed = false;
     for (Value *V : ValsToClear) {
-      // If a value was marked overdefined in OldSucc, and is here too...
-      auto OI = OverDefinedCache.find(ToUpdate);
-      if (OI == OverDefinedCache.end())
-        continue;
-      SmallPtrSetImpl<Value *> &ValueSet = OI->second;
+      // TODO: count and erase can be converted to a find/erase(itr) pattern
       if (!ValueSet.count(V))
         continue;
 
       ValueSet.erase(V);
-      if (ValueSet.empty())
-        OverDefinedCache.erase(OI);
 
       // If we removed anything, then we potentially need to update
       // blocks successors too.
       changed = true;
+
+      if (ValueSet.empty()) {
+        OverDefinedCache.erase(OI);
+        break;
+      }
     }
 
     if (!changed) continue;