aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-13 19:05:20 +0000
committerChris Lattner <sabre@nondot.org>2006-07-13 19:05:20 +0000
commit262041892d7f821a86ea96c0282ff1e53aac1888 (patch)
treee0a07fdff1790e98d4606bebe5a6cb83c71cdb78
parent0b7ae54da7a3bf40a5dbfa4a0b6b310370b8ad96 (diff)
downloadexternal_llvm-262041892d7f821a86ea96c0282ff1e53aac1888.zip
external_llvm-262041892d7f821a86ea96c0282ff1e53aac1888.tar.gz
external_llvm-262041892d7f821a86ea96c0282ff1e53aac1888.tar.bz2
Revert this patch temporarily until PR831 is fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29134 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp46
1 files changed, 15 insertions, 31 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index 6379329..a469160 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -79,7 +79,6 @@ namespace {
AU.addRequired<ScalarEvolution>();
AU.addRequired<LoopInfo>();
AU.addPreservedID(LoopSimplifyID);
- AU.addPreservedID(LCSSAID);
AU.setPreservesCFG();
}
private:
@@ -326,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()) {
@@ -347,35 +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 && !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);
- }
- }
+ 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())