diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-11-27 22:05:15 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-11-27 22:05:15 +0000 |
| commit | 2be52e72aeb2aa94444445330e7e92cedc71489c (patch) | |
| tree | 97e219780e833462fbda54b35960f1f56435c8d9 /llvm/lib/Transforms | |
| parent | 03ff379911de2ba44ea53008b248a61f762ec1b7 (diff) | |
| download | bcm5719-llvm-2be52e72aeb2aa94444445330e7e92cedc71489c.tar.gz bcm5719-llvm-2be52e72aeb2aa94444445330e7e92cedc71489c.zip | |
Rework InsertPHITranslatedPointer to handle the recursive case, this
fixes PR5630 and sets the stage for the next phase of goodness (testcase
pending).
llvm-svn: 90019
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 72eb9002ce5..18cfd2208da 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1432,31 +1432,21 @@ bool GVN::processNonLocalLoad(LoadInst *LI, return false; } - // If the loaded pointer is PHI node defined in this block, do PHI translation - // to get its value in the predecessor. - Value *LoadPtr = MD->PHITranslatePointer(LI->getOperand(0), - LoadBB, UnavailablePred, TD); - // Make sure the value is live in the predecessor. MemDep found a computation - // of LPInst with the right value, but that does not dominate UnavailablePred, - // then we can't use it. - if (Instruction *LPInst = dyn_cast_or_null<Instruction>(LoadPtr)) - if (!DT->dominates(LPInst->getParent(), UnavailablePred)) - LoadPtr = 0; - - // If we don't have a computation of this phi translated value, try to insert - // one. + // Do PHI translation to get its value in the predecessor if necessary. The + // returned pointer (if non-null) is guaranteed to dominate UnavailablePred. + // + // FIXME: This may insert a computation, but we don't tell scalar GVN + // optimization stuff about it. How do we do this? + Value *LoadPtr = + MD->InsertPHITranslatedPointer(LI->getOperand(0), LoadBB, + UnavailablePred, TD, *DT); + + // If we couldn't find or insert a computation of this phi translated value, + // we fail PRE. if (LoadPtr == 0) { - LoadPtr = MD->InsertPHITranslatedPointer(LI->getOperand(0), - LoadBB, UnavailablePred, TD); - if (LoadPtr == 0) { - DEBUG(errs() << "COULDN'T INSERT PHI TRANSLATED VALUE OF: " - << *LI->getOperand(0) << "\n"); - return false; - } - - // FIXME: This inserts a computation, but we don't tell scalar GVN - // optimization stuff about it. How do we do this? - DEBUG(errs() << "INSERTED PHI TRANSLATED VALUE: " << *LoadPtr << "\n"); + DEBUG(errs() << "COULDN'T INSERT PHI TRANSLATED VALUE OF: " + << *LI->getOperand(0) << "\n"); + return false; } // Make sure it is valid to move this load here. We have to watch out for: |

