diff options
author | Owen Anderson <resistor@mac.com> | 2006-07-11 07:25:33 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2006-07-11 07:25:33 +0000 |
commit | 15b1f7d2cdc61f9e8c99b66302c9f9ef77badd80 (patch) | |
tree | 400e5784d17f2bc8adf64f597d9f705f05d1c1ef /llvm/lib/Transforms | |
parent | 298ef37e0240cf11f34745608239039c4118cdee (diff) | |
download | bcm5719-llvm-15b1f7d2cdc61f9e8c99b66302c9f9ef77badd80.tar.gz bcm5719-llvm-15b1f7d2cdc61f9e8c99b66302c9f9ef77badd80.zip |
Revert my indvars changes because they were breaking things. Unfortunately this
didn't start showing up until after the recent instcombine fixes.
llvm-svn: 29102
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index f238a94fa68..a46916077ae 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -325,8 +325,20 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) { for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) { Instruction *User = cast<Instruction>(*UI); - if (!L->contains(User->getParent())) + if (!L->contains(User->getParent())) { + // If this is a PHI node in the exit block and we're inserting, + // into the exit block, it must have a single entry. In this + // case, we can't insert the code after the PHI and have the PHI + // still use it. Instead, don't insert the the PHI. + if (PHINode *PN = dyn_cast<PHINode>(User)) { + // FIXME: This is a case where LCSSA pessimizes code, this + // should be fixed better. + if (PN->getNumOperands() == 2 && + PN->getParent() == BlockToInsertInto) + continue; + } ExtraLoopUsers.push_back(User); + } } if (!ExtraLoopUsers.empty()) { @@ -346,34 +358,8 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) { // 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) { - PHINode* PN = dyn_cast<PHINode>(ExtraLoopUsers[i]); - if (PN && PN->getParent() == BlockToInsertInto) { - // We're dealing with an LCSSA Phi. Handle it specially. - Instruction* LCSSAInsertPt = BlockToInsertInto->begin(); - - Instruction* NewInstr = dyn_cast<Instruction>(NewVal); - if (Instruction* NewInstr = dyn_cast<Instruction>(NewVal)) - 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); - } - } + for (unsigned i = 0, e = ExtraLoopUsers.size(); i != e; ++i) + ExtraLoopUsers[i]->replaceUsesOfWith(I, NewVal); // If this instruction is dead now, schedule it to be removed. if (I->use_empty()) |