#include "llvm/Analysis/PHITransAddr.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/InstructionSimplify.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
void PHITransAddr::dump() const {
if (Addr == 0) {
- errs() << "PHITransAddr: null\n";
+ dbgs() << "PHITransAddr: null\n";
return;
}
- errs() << "PHITransAddr: " << *Addr << "\n";
+ dbgs() << "PHITransAddr: " << *Addr << "\n";
for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
- errs() << " Input #" << i << " is " << *InstInputs[i] << "\n";
+ dbgs() << " Input #" << i << " is " << *InstInputs[i] << "\n";
}
RemoveInstInputs(LHS, InstInputs);
return AddAsInput(Res);
}
+
+ // If we didn't modify the add, just return it.
+ if (LHS == Inst->getOperand(0) && RHS == Inst->getOperand(1))
+ return Inst;
// Otherwise, see if we have this add available somewhere.
for (Value::use_iterator UI = LHS->use_begin(), E = LHS->use_end();
UI != E; ++UI) {
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(*UI))
- if (BO->getOperand(0) == LHS && BO->getOperand(1) == RHS &&
+ if (BO->getOpcode() == Instruction::Add &&
+ BO->getOperand(0) == LHS && BO->getOperand(1) == RHS &&
BO->getParent()->getParent() == CurBB->getParent())
return BO;
}