OSDN Git Service

Reapply r121886, and also update DecomposeGEPExpression to keep
authorDan Gohman <gohman@apple.com>
Wed, 15 Dec 2010 20:49:55 +0000 (20:49 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 15 Dec 2010 20:49:55 +0000 (20:49 +0000)
it in sync.

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

lib/Analysis/BasicAliasAnalysis.cpp
lib/Analysis/ValueTracking.cpp

index fc996fb..1a526fc 100644 (file)
@@ -27,6 +27,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Analysis/CaptureTracking.h"
 #include "llvm/Analysis/MemoryBuiltins.h"
+#include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -262,6 +263,14 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
       V = Op->getOperand(0);
       continue;
     }
+
+    if (const Instruction *I = dyn_cast<Instruction>(V))
+      // TODO: Get a DominatorTree and use it here.
+      if (const Value *Simplified =
+            SimplifyInstruction(const_cast<Instruction *>(I), TD)) {
+        V = Simplified;
+        continue;
+      }
     
     const GEPOperator *GEPOp = dyn_cast<GEPOperator>(Op);
     if (GEPOp == 0)
index ae253ab..7506295 100644 (file)
@@ -1441,6 +1441,14 @@ Value *llvm::GetUnderlyingObject(Value *V, unsigned MaxLookup) {
         return V;
       V = GA->getAliasee();
     } else {
+      // See if InstructionSimplify knows any relevant tricks.
+      if (Instruction *I = dyn_cast<Instruction>(V))
+        // TODO: Aquire TargetData and DominatorTree and use them.
+        if (Value *Simplified = SimplifyInstruction(I, 0, 0)) {
+          V = Simplified;
+          continue;
+        }
+
       return V;
     }
     assert(V->getType()->isPointerTy() && "Unexpected operand type!");