[llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 23 15:27:06 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
IndVarSimplify.cpp updated: 1.37 -> 1.38
---
Log message:
Fix bug: IndVarsSimplify/2003-09-23-NotAtTop.ll
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.37 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.38
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.37 Fri Sep 12 11:45:01 2003
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Sep 23 15:26:48 2003
@@ -76,8 +76,8 @@
// indvar. If we don't have one, add one now...
if (!Canonical) {
// Create the PHI node for the new induction variable, and insert the phi
- // node at the end of the other phi nodes...
- PHINode *PN = new PHINode(Type::UIntTy, "cann-indvar", AfterPHIIt);
+ // node at the start of the PHI nodes...
+ PHINode *PN = new PHINode(Type::UIntTy, "cann-indvar", Header->begin());
// Create the increment instruction to add one to the counter...
Instruction *Add = BinaryOperator::create(Instruction::Add, PN,
@@ -108,6 +108,12 @@
Canonical = &IndVars.back();
++NumInserted;
Changed = true;
+ } else {
+ // If we have a canonical induction variable, make sure that it is the first
+ // one in the basic block.
+ if (&Header->front() != Canonical->Phi)
+ Header->getInstList().splice(Header->begin(), Header->getInstList(),
+ Canonical->Phi);
}
DEBUG(std::cerr << "Induction variables:\n");
More information about the llvm-commits
mailing list