Reapply r121886, and also update DecomposeGEPExpression to keep
it in sync.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121895 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index ae253ab..7506295 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -1441,6 +1441,14 @@
         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!");