summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2005-02-28 00:08:56 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2005-02-28 00:08:56 +0000
commitdcaa48b5c40cd3c21d4cc0b1113be890df67a711 (patch)
tree16a0b7daa186f1acefebc0536a258388080e2457 /llvm/lib/Transforms
parentfd63d3af0df49810f196e944a7f71e0ba29a596b (diff)
downloadbcm5719-llvm-dcaa48b5c40cd3c21d4cc0b1113be890df67a711.tar.gz
bcm5719-llvm-dcaa48b5c40cd3c21d4cc0b1113be890df67a711.zip
Fix crash in LSR due to attempt to remove original induction variable. However,
for reasons explained in the comments, I also deactivated this code as it needs more thought. llvm-svn: 20367
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 19381b9e8ea..6494490167f 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -78,9 +78,14 @@ DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
Instruction *I = *Insts.begin();
Insts.erase(Insts.begin());
if (isInstructionTriviallyDead(I)) {
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
- Insts.insert(U);
+ for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
+ // Note: the PHI nodes had dropAllReferences() called on it, so its
+ // operands will all be NULL.
+ Value *V = I->getOperand(i);
+ if (V)
+ if (Instruction *U = dyn_cast<Instruction>(V))
+ Insts.insert(U);
+ }
I->getParent()->getInstList().erase(I);
Changed = true;
}
@@ -237,6 +242,11 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
// 4. the add is used by the cann indvar
// If all four cases above are true, then we can remove both the add and
// the cann indvar.
+#if 0
+ // FIXME: it's not clear this code is correct. An induction variable with
+ // but one use, an increment, implies an infinite loop. Not illegal, but
+ // of questionable utility. It also does not update the loop info with the
+ // new induction variable.
if (PN->hasOneUse()) {
BinaryOperator *BO = dyn_cast<BinaryOperator>(*(PN->use_begin()));
if (BO && BO->getOpcode() == Instruction::Add)
@@ -250,5 +260,6 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
}
}
}
+#endif
}
}
OpenPOWER on IntegriCloud