///
static void PrintOps(Instruction *I, const SmallVectorImpl<ValueEntry> &Ops) {
Module *M = I->getParent()->getParent()->getParent();
- errs() << Instruction::getOpcodeName(I->getOpcode()) << " "
+ dbgs() << Instruction::getOpcodeName(I->getOpcode()) << " "
<< *Ops[0].Op->getType() << '\t';
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
- errs() << "[ ";
- WriteAsOperand(errs(), Ops[i].Op, false, M);
- errs() << ", #" << Ops[i].Rank << "] ";
+ dbgs() << "[ ";
+ WriteAsOperand(dbgs(), Ops[i].Op, false, M);
+ dbgs() << ", #" << Ops[i].Rank << "] ";
}
}
#endif
(!BinaryOperator::isNot(I) && !BinaryOperator::isNeg(I)))
++Rank;
- //DEBUG(errs() << "Calculated Rank[" << V->getName() << "] = "
+ //DEBUG(dbgs() << "Calculated Rank[" << V->getName() << "] = "
// << Rank << "\n");
return ValueRankMap[I] = Rank;
isReassociableOp(RHS, I->getOpcode()) &&
"Not an expression that needs linearization?");
- DEBUG(errs() << "Linear" << *LHS << '\n' << *RHS << '\n' << *I << '\n');
+ DEBUG(dbgs() << "Linear" << *LHS << '\n' << *RHS << '\n' << *I << '\n');
// Move the RHS instruction to live immediately before I, avoiding breaking
// dominator properties.
++NumLinear;
MadeChange = true;
- DEBUG(errs() << "Linearized: " << *I << '\n');
+ DEBUG(dbgs() << "Linearized: " << *I << '\n');
// If D is part of this expression tree, tail recurse.
if (isReassociableOp(I->getOperand(1), I->getOpcode()))
if (I->getOperand(0) != Ops[i].Op ||
I->getOperand(1) != Ops[i+1].Op) {
Value *OldLHS = I->getOperand(0);
- DEBUG(errs() << "RA: " << *I << '\n');
+ DEBUG(dbgs() << "RA: " << *I << '\n');
I->setOperand(0, Ops[i].Op);
I->setOperand(1, Ops[i+1].Op);
- DEBUG(errs() << "TO: " << *I << '\n');
+ DEBUG(dbgs() << "TO: " << *I << '\n');
MadeChange = true;
++NumChanged;
assert(i+2 < Ops.size() && "Ops index out of range!");
if (I->getOperand(1) != Ops[i].Op) {
- DEBUG(errs() << "RA: " << *I << '\n');
+ DEBUG(dbgs() << "RA: " << *I << '\n');
I->setOperand(1, Ops[i].Op);
- DEBUG(errs() << "TO: " << *I << '\n');
+ DEBUG(dbgs() << "TO: " << *I << '\n');
MadeChange = true;
++NumChanged;
}
Sub->replaceAllUsesWith(New);
Sub->eraseFromParent();
- DEBUG(errs() << "Negated: " << *New << '\n');
+ DEBUG(dbgs() << "Negated: " << *New << '\n');
return New;
}
SmallVector<ValueEntry, 8> Ops;
LinearizeExprTree(I, Ops);
- DEBUG(errs() << "RAIn:\t"; PrintOps(I, Ops); errs() << '\n');
+ DEBUG(dbgs() << "RAIn:\t"; PrintOps(I, Ops); dbgs() << '\n');
// Now that we have linearized the tree to a list and have gathered all of
// the operands and their ranks, sort the operands by their rank. Use a
if (Value *V = OptimizeExpression(I, Ops)) {
// This expression tree simplified to something that isn't a tree,
// eliminate it.
- DEBUG(errs() << "Reassoc to scalar: " << *V << '\n');
+ DEBUG(dbgs() << "Reassoc to scalar: " << *V << '\n');
I->replaceAllUsesWith(V);
RemoveDeadBinaryOp(I);
++NumAnnihil;
Ops.insert(Ops.begin(), Tmp);
}
- DEBUG(errs() << "RAOut:\t"; PrintOps(I, Ops); errs() << '\n');
+ DEBUG(dbgs() << "RAOut:\t"; PrintOps(I, Ops); dbgs() << '\n');
if (Ops.size() == 1) {
// This expression tree simplified to something that isn't a tree,