#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetLowering.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
Start = SCEVAddExpr::get(Start, AddRec->getOperand(0));
if (!isa<SCEVConstant>(AddRec->getOperand(1)))
- DEBUG(std::cerr << "[" << L->getHeader()->getName()
- << "] Variable stride: " << *AddRec << "\n");
+ DOUT << "[" << L->getHeader()->getName()
+ << "] Variable stride: " << *AddRec << "\n";
Stride = AddRec->getOperand(1);
// Check that all constant strides are the unsigned type, we don't want to
// don't recurse into it.
bool AddUserToIVUsers = false;
if (LI->getLoopFor(User->getParent()) != L) {
- DEBUG(std::cerr << "FOUND USER in other loop: " << *User
- << " OF SCEV: " << *ISE << "\n");
+ DOUT << "FOUND USER in other loop: " << *User
+ << " OF SCEV: " << *ISE << "\n";
AddUserToIVUsers = true;
} else if (!AddUsersIfInteresting(User, L, Processed)) {
- DEBUG(std::cerr << "FOUND USER: " << *User
- << " OF SCEV: " << *ISE << "\n");
+ DOUT << "FOUND USER: " << *User
+ << " OF SCEV: " << *ISE << "\n";
AddUserToIVUsers = true;
}
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
StrideUses.addUser(NewStart, User, I);
StrideUses.Users.back().isUseOfPostIncrementedValue = true;
- DEBUG(std::cerr << " USING POSTINC SCEV, START=" << *NewStart<< "\n");
+ DOUT << " USING POSTINC SCEV, START=" << *NewStart<< "\n";
} else {
StrideUses.addUser(Start, User, I);
}
}
void BasedUser::dump() const {
- std::cerr << " Base=" << *Base;
- std::cerr << " Imm=" << *Imm;
+ llvm_cerr << " Base=" << *Base;
+ llvm_cerr << " Imm=" << *Imm;
if (EmittedBase)
- std::cerr << " EB=" << *EmittedBase;
+ llvm_cerr << " EB=" << *EmittedBase;
- std::cerr << " Inst: " << *Inst;
+ llvm_cerr << " Inst: " << *Inst;
}
Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,
Value *NewVal = InsertCodeForBaseAtPosition(NewBase, Rewriter, Inst, L);
// Replace the use of the operand Value with the new Phi we just created.
Inst->replaceUsesOfWith(OperandValToReplace, NewVal);
- DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
+ DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
return;
}
Rewriter.clear();
}
}
- DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
+ DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
}
unsigned RewriteFactor = CheckForIVReuse(Stride, ReuseIV,
CommonExprs->getType());
if (RewriteFactor != 0) {
- DEBUG(std::cerr << "BASED ON IV of STRIDE " << *ReuseIV.Stride
- << " and BASE " << *ReuseIV.Base << " :\n");
+ DOUT << "BASED ON IV of STRIDE " << *ReuseIV.Stride
+ << " and BASE " << *ReuseIV.Base << " :\n";
NewPHI = ReuseIV.PHI;
IncV = ReuseIV.IncV;
}
// Now that we know what we need to do, insert the PHI node itself.
//
- DEBUG(std::cerr << "INSERTING IV of STRIDE " << *Stride << " and BASE "
- << *CommonExprs << " :\n");
+ DOUT << "INSERTING IV of STRIDE " << *Stride << " and BASE "
+ << *CommonExprs << " :\n";
SCEVExpander Rewriter(*SE, *LI);
SCEVExpander PreheaderRewriter(*SE, *LI);
while (!UsersToProcess.empty()) {
SCEVHandle Base = UsersToProcess.back().Base;
- DEBUG(std::cerr << " INSERTING code for BASE = " << *Base << ":\n");
+ DOUT << " INSERTING code for BASE = " << *Base << ":\n";
// Emit the code for Base into the preheader.
Value *BaseV = PreheaderRewriter.expandCodeFor(Base, PreInsertPt,
bool HasOneStride = IVUsesByStride.size() == 1;
#ifndef NDEBUG
- DEBUG(std::cerr << "\nLSR on ");
+ DOUT << "\nLSR on ";
DEBUG(L->dump());
#endif