Fix regression from r151466: an we can't replace uses of an instruction reachable...
[oota-llvm.git] / lib / Analysis / InstructionSimplify.cpp
index dd8b2634da69bb2a7d8a18db81bb8c7794d3cf11..44f870c81795e5831590511378127d1c732bbaa7 100644 (file)
@@ -94,9 +94,13 @@ static bool ValueDominatesPHI(Value *V, PHINode *P, const DominatorTree *DT) {
     return true;
 
   // If we have a DominatorTree then do a precise test.
-  if (DT)
-    return !DT->isReachableFromEntry(P->getParent()) ||
-      !DT->isReachableFromEntry(I->getParent()) || DT->dominates(I, P);
+  if (DT) {
+    if (!DT->isReachableFromEntry(P->getParent()))
+      return true;
+    if (!DT->isReachableFromEntry(I->getParent()))
+      return false;
+    return DT->dominates(I, P);
+  }
 
   // Otherwise, if the instruction is in the entry block, and is not an invoke,
   // then it obviously dominates all phi nodes.