Fix phi translation in load PRE to agree with the phi
translation done by memdep, and reenable gep translation
again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89992 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index a8f39c1..e878050 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1427,13 +1427,19 @@
// If the loaded pointer is PHI node defined in this block, do PHI translation
// to get its value in the predecessor.
- Value *LoadPtr = LI->getOperand(0)->DoPHITranslation(LoadBB, UnavailablePred);
+ Value *LoadPtr = MD->PHITranslatePointer(LI->getOperand(0),
+ LoadBB, UnavailablePred, TD);
+ if (LoadPtr == 0) {
+ DEBUG(errs() << "COULDN'T PRE LOAD BECAUSE PTR CAN'T BE PHI TRANSLATED: "
+ << *LI->getOperand(0) << '\n' << *LI << "\n");
+ return false;
+ }
// Make sure the value is live in the predecessor. If it was defined by a
// non-PHI instruction in this block, we don't know how to recompute it above.
if (Instruction *LPInst = dyn_cast<Instruction>(LoadPtr))
if (!DT->dominates(LPInst->getParent(), UnavailablePred)) {
- DEBUG(errs() << "COULDN'T PRE LOAD BECAUSE PTR IS UNAVAILABLE IN PRED: "
+ DEBUG(errs() << "COULDN'T PRE LOAD BECAUSE PTR DOES NOT DOMINATE PRED: "
<< *LPInst << '\n' << *LI << "\n");
return false;
}