diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-11 22:23:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-11 22:23:32 +0000 |
commit | 34399dda2d202a16301de9c4b6f72d1cd6263e18 (patch) | |
tree | 6c16b69de8d7b5c24a344093cfed5c679134a339 /llvm | |
parent | 99146bb2a7c24bea64d14c08e6a7f5448e4dc4ab (diff) | |
download | bcm5719-llvm-34399dda2d202a16301de9c4b6f72d1cd6263e18.tar.gz bcm5719-llvm-34399dda2d202a16301de9c4b6f72d1cd6263e18.zip |
Fix LICM/2003-12-11-SinkingToPHI.ll, and quite possibly all of the other known problems in the universe.
llvm-svn: 10409
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 0d8a848cc0d..3365e64af05 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -337,9 +337,18 @@ bool LICM::canSinkOrHoistInst(Instruction &I) { /// exit blocks of the loop. /// bool LICM::isNotUsedInLoop(Instruction &I) { - for (Value::use_iterator UI = I.use_begin(), E = I.use_end(); UI != E; ++UI) - if (CurLoop->contains(cast<Instruction>(*UI)->getParent())) + for (Value::use_iterator UI = I.use_begin(), E = I.use_end(); UI != E; ++UI) { + Instruction *User = cast<Instruction>(*UI); + if (PHINode *PN = dyn_cast<PHINode>(User)) { + // PHI node uses occur in predecessor blocks! + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + if (PN->getIncomingValue(i) == &I) + if (CurLoop->contains(PN->getIncomingBlock(i))) + return false; + } else if (CurLoop->contains(User->getParent())) { return false; + } + } return true; } |