aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Analysis/PHITransAddr.h2
-rw-r--r--lib/Analysis/PHITransAddr.cpp9
2 files changed, 7 insertions, 4 deletions
diff --git a/include/llvm/Analysis/PHITransAddr.h b/include/llvm/Analysis/PHITransAddr.h
index 678d405..1f4f341 100644
--- a/include/llvm/Analysis/PHITransAddr.h
+++ b/include/llvm/Analysis/PHITransAddr.h
@@ -88,7 +88,7 @@ private:
/// PHITranslateSubExpr if it dominates PredBB, otherwise return null.
Value *GetAvailablePHITranslatedSubExpr(Value *V,
BasicBlock *CurBB, BasicBlock *PredBB,
- const DominatorTree &DT);
+ const DominatorTree &DT) const;
/// InsertPHITranslatedSubExpr - Insert a computation of the PHI translated
/// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
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 @@ static bool CanPHITrans(Instruction *Inst) {
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 @@ bool PHITransAddr::PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB) {
/// 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))