Changes in directory llvm/lib/Transforms/Scalar:
IndVarSimplify.cpp updated: 1.87 -> 1.88 --- Log message: Hopefully the final attempt at making IndVars preserve LCSSA. This should fix PR 831: http://llvm.org/PR831 . --- Diffs of the changes: (+30 -2) IndVarSimplify.cpp | 32 ++++++++++++++++++++++++++++++-- 1 files changed, 30 insertions(+), 2 deletions(-) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.87 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.88 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.87 Thu Jul 13 14:05:20 2006 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Jul 14 13:49:15 2006 @@ -358,8 +358,36 @@ // Rewrite any users of the computed value outside of the loop // with the newly computed value. - for (unsigned i = 0, e = ExtraLoopUsers.size(); i != e; ++i) - ExtraLoopUsers[i]->replaceUsesOfWith(I, NewVal); + for (unsigned i = 0, e = ExtraLoopUsers.size(); i != e; ++i) { + PHINode* PN = dyn_cast<PHINode>(ExtraLoopUsers[i]); + if (PN && PN->getNumOperands() == 2 && + !L->contains(PN->getParent())) { + // We're dealing with an LCSSA Phi. Handle it specially. + Instruction* LCSSAInsertPt = BlockToInsertInto->begin(); + + Instruction* NewInstr = dyn_cast<Instruction>(NewVal); + if (NewInstr && !isa<PHINode>(NewInstr) && + !L->contains(NewInstr->getParent())) + for (unsigned j = 0; j < NewInstr->getNumOperands(); ++j){ + Instruction* PredI = + dyn_cast<Instruction>(NewInstr->getOperand(j)); + if (PredI && L->contains(PredI->getParent())) { + PHINode* NewLCSSA = new PHINode(PredI->getType(), + PredI->getName() + ".lcssa", + LCSSAInsertPt); + NewLCSSA->addIncoming(PredI, + BlockToInsertInto->getSinglePredecessor()); + + NewInstr->replaceUsesOfWith(PredI, NewLCSSA); + } + } + + PN->replaceAllUsesWith(NewVal); + PN->eraseFromParent(); + } else { + ExtraLoopUsers[i]->replaceUsesOfWith(I, NewVal); + } + } // If this instruction is dead now, schedule it to be removed. if (I->use_empty()) _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits