Fix another instance where PHI nodes need special treatment.
[oota-llvm.git] / lib / Transforms / Utils / LCSSA.cpp
index 37ab7ee7ff2c6b3ff8df1a40e3b48c2fe77f8fef..3c70f735e88c03f1c8e0b67dfd41aeb55ecc0b59 100644 (file)
@@ -215,6 +215,12 @@ void LCSSA::processInstruction(Instruction* Instr,
   for (Instruction::use_iterator UI = Instr->use_begin(), UE = Instr->use_end();
        UI != UE; ++UI) {
     Instruction* use = cast<Instruction>(*UI);
+    BasicBlock* UserBB = use->getParent();
+    if (PHINode* p = dyn_cast<PHINode>(use)) {
+      unsigned OperandNo = UI.getOperandNo();
+      UserBB = p->getIncomingBlock(OperandNo/2);
+    }
+    
     // Don't need to update uses within the loop body.
     if (!inLoop(use->getParent()))
       Uses.push_back(use);