There's no need to consider PHI nodes in the same block as the instruction
[oota-llvm.git] / lib / Transforms / Utils / SSI.cpp
index caafb318e8b3c0f8a46241600ff31ca8c5d4ce69..0585561a30b6eef7b964c44e66d17ddddb60437e 100644 (file)
@@ -282,12 +282,16 @@ void SSI::substituteUse(Instruction *I) {
 }
 
 /// Test if the BasicBlock BB dominates any use or definition of value.
+/// If it dominates a phi instruction that is on the same BasicBlock,
+/// that does not count.
 ///
 bool SSI::dominateAny(BasicBlock *BB, Instruction *value) {
   for (Value::use_iterator begin = value->use_begin(),
        end = value->use_end(); begin != end; ++begin) {
     Instruction *I = cast<Instruction>(*begin);
     BasicBlock *BB_father = I->getParent();
+    if (BB == BB_father && isa<PHINode>(I))
+      continue;
     if (DT_->dominates(BB, BB_father)) {
       return true;
     }