[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Jeff Cohen
jeffc at jolt-lang.org
Sun Feb 27 16:09:07 PST 2005
Changes in directory llvm/lib/Transforms/Scalar:
LoopStrengthReduce.cpp updated: 1.3 -> 1.4
---
Log message:
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.
---
Diffs of the changes: (+14 -3)
LoopStrengthReduce.cpp | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.3 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.4
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.3 Sun Feb 27 15:08:04 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Feb 27 18:08:56 2005
@@ -78,9 +78,14 @@
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 @@
// 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 @@
}
}
}
+#endif
}
}
More information about the llvm-commits
mailing list