[llvm-commits] [llvm] r90016 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Chris Lattner sabre at nondot.org
Fri Nov 27 12:25:30 PST 2009


Author: lattner
Date: Fri Nov 27 14:25:30 2009
New Revision: 90016

URL: http://llvm.org/viewvc/llvm-project?rev=90016&view=rev
Log:
recursively phi translate bitcast operands too, for consistency.

Modified:
    llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90016&r1=90015&r2=90016&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Fri Nov 27 14:25:30 2009
@@ -693,21 +693,22 @@
   
   // We can handle bitcast of a PHI, but the PHI needs to be in the same block
   // as the bitcast.
-  if (BitCastInst *BC = dyn_cast<BitCastInst>(Inst))
-    // FIXME: Allow any phi translatable operand.
-    if (PHINode *PN = dyn_cast<PHINode>(BC->getOperand(0)))
-      if (PN->getParent() == BC->getParent())
-        return true;
+  if (BitCastInst *BC = dyn_cast<BitCastInst>(Inst)) {
+    Instruction *OpI = dyn_cast<Instruction>(BC->getOperand(0));
+    if (OpI == 0 || OpI->getParent() != Inst->getParent())
+      return true;
+    return isPHITranslatable(OpI);
+  }
   
   // We can translate a GEP if all of its operands defined in this block are phi
   // translatable. 
   if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
     for (unsigned i = 0, e = GEP->getNumOperands(); i != e; ++i) {
-      Instruction *GEPOpI = dyn_cast<Instruction>(GEP->getOperand(i));
-      if (GEPOpI == 0 || GEPOpI->getParent() != Inst->getParent())
+      Instruction *OpI = dyn_cast<Instruction>(GEP->getOperand(i));
+      if (OpI == 0 || OpI->getParent() != Inst->getParent())
         continue;
       
-      if (!isPHITranslatable(GEPOpI))
+      if (!isPHITranslatable(OpI))
         return false;
     }
     return true;
@@ -715,10 +716,10 @@
   
   if (Inst->getOpcode() == Instruction::Add &&
       isa<ConstantInt>(Inst->getOperand(1))) {
-    Instruction *GEPOpI = dyn_cast<Instruction>(Inst->getOperand(0));
-    if (GEPOpI == 0 || GEPOpI->getParent() != Inst->getParent())
+    Instruction *OpI = dyn_cast<Instruction>(Inst->getOperand(0));
+    if (OpI == 0 || OpI->getParent() != Inst->getParent())
       return true;
-    return isPHITranslatable(GEPOpI);
+    return isPHITranslatable(OpI);
   }
 
   //   cerr << "MEMDEP: Could not PHI translate: " << *Pointer;
@@ -745,9 +746,9 @@
   
   // Handle bitcast of PHI.
   if (BitCastInst *BC = dyn_cast<BitCastInst>(Inst)) {
-    // FIXME: Recurse!
-    PHINode *BCPN = cast<PHINode>(BC->getOperand(0));
-    Value *PHIIn = BCPN->getIncomingValueForBlock(Pred);
+    // PHI translate the input operand.
+    Value *PHIIn = PHITranslatePointer(BC->getOperand(0), CurBB, Pred, TD);
+    if (PHIIn == 0) return 0;
     
     // Constants are trivial to phi translate.
     if (Constant *C = dyn_cast<Constant>(PHIIn))
@@ -779,14 +780,10 @@
       }
       
       // If the operand is a phi node, do phi translation.
-      if (Value *InOp = PHITranslatePointer(GEPOp, CurBB, Pred, TD)) {
-        GEPOps.push_back(InOp);
-        continue;
-      }
+      Value *InOp = PHITranslatePointer(GEPOp, CurBB, Pred, TD);
+      if (InOp == 0) return 0;
       
-      // Otherwise, we can't PHI translate this random value defined in this
-      // block.
-      return 0;
+      GEPOps.push_back(InOp);
     }
     
     // Simplify the GEP to handle 'gep x, 0' -> x etc.





More information about the llvm-commits mailing list