[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Aug 3 16:30:19 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
LoopStrengthReduce.cpp updated: 1.25 -> 1.26
---
Log message:
improve debug output
---
Diffs of the changes: (+9 -4)
LoopStrengthReduce.cpp | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.25 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.26
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.25 Wed Aug 3 17:51:21 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Wed Aug 3 18:30:08 2005
@@ -15,6 +15,7 @@
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "loop-reduce"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
@@ -553,6 +554,8 @@
BasicBlock *LatchBlock =
SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader);
+ DEBUG(std::cerr << "INSERTING IVs of STRIDE " << *Stride << ":\n");
+
// FIXME: This loop needs increasing levels of intelligence.
// STAGE 0: just emit everything as its own base.
// STAGE 1: factor out common vars from bases, and try and push resulting
@@ -565,7 +568,9 @@
std::sort(UsersToProcess.begin(), UsersToProcess.end());
while (!UsersToProcess.empty()) {
SCEVHandle Base = UsersToProcess.front().first;
-
+
+ DEBUG(std::cerr << " INSERTING PHI with BASE = " << *Base << ":\n");
+
// Create a new Phi for this base, and stick it in the loop header.
const Type *ReplacedTy = Base->getType();
PHINode *NewPHI = new PHINode(ReplacedTy, "iv.", PhiInsertBefore);
@@ -595,14 +600,14 @@
Rewriter.clear();
SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(NewPHI),
User.Imm);
- Value *Replaced = UsersToProcess.front().second.OperandValToReplace;
+ Value *Replaced = User.OperandValToReplace;
Value *newVal = Rewriter.expandCodeFor(NewValSCEV, User.Inst,
Replaced->getType());
// Replace the use of the operand Value with the new Phi we just created.
- DEBUG(std::cerr << "REPLACING: " << *Replaced << "IN: " <<
- *User.Inst << "WITH: "<< *newVal << '\n');
User.Inst->replaceUsesOfWith(Replaced, newVal);
+ DEBUG(std::cerr << " CHANGED: IMM =" << *User.Imm << " Inst = "
+ << *User.Inst);
// Mark old value we replaced as possibly dead, so that it is elminated
// if we just replaced the last use of that value.
More information about the llvm-commits
mailing list