fix a typo (and -> add) and fix GetAvailablePHITranslatedSubExpr to not
authorChris Lattner <sabre@nondot.org>
Tue, 8 Dec 2009 06:06:26 +0000 (06:06 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 8 Dec 2009 06:06:26 +0000 (06:06 +0000)
side-effect the current object.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90837 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/PHITransAddr.h
lib/Analysis/PHITransAddr.cpp

index 678d40561e8db6ff6e98b334b605ebd2329ef7b3..1f4f3416da8dce53d088a0de329bb8224880a09c 100644 (file)
@@ -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
index bb95926c5263f7429a283ddf04a1b3d374c0ca6b..98cea9bb4bd6cc233af20f1885c8d9b95376e956 100644 (file)
@@ -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))