fix a typo (and -> add) and fix GetAvailablePHITranslatedSubExpr to not
side-effect the current object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90837 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/PHITransAddr.cpp b/lib/Analysis/PHITransAddr.cpp
index bb95926..98cea9b 100644
--- a/lib/Analysis/PHITransAddr.cpp
+++ b/lib/Analysis/PHITransAddr.cpp
@@ -22,7 +22,7 @@
isa<GetElementPtrInst>(Inst))
return true;
- if (Inst->getOpcode() == Instruction::And &&
+ if (Inst->getOpcode() == Instruction::Add &&
isa<ConstantInt>(Inst->getOperand(1)))
return true;
@@ -205,9 +205,12 @@
/// PHITranslateSubExpr if it dominates PredBB, otherwise return null.
Value *PHITransAddr::
GetAvailablePHITranslatedSubExpr(Value *V, BasicBlock *CurBB,BasicBlock *PredBB,
- const DominatorTree &DT) {
+ const DominatorTree &DT) const {
+ PHITransAddr Tmp(V, TD);
+ Tmp.PHITranslateValue(CurBB, PredBB);
+
// See if PHI translation succeeds.
- V = PHITranslateSubExpr(V, CurBB, PredBB);
+ V = Tmp.getAddr();
// Make sure the value is live in the predecessor.
if (Instruction *Inst = dyn_cast_or_null<Instruction>(V))