diff options
author | Chris Lattner <sabre@nondot.org> | 2010-08-29 18:22:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-08-29 18:22:25 +0000 |
commit | 0de5cad74d8d2987b92b8d76af3f1eab988b3c7b (patch) | |
tree | eb94a7c72f1cad30c16c868f9f6dde5213279dfc /lib/Transforms/Scalar | |
parent | d9a5daeb7719c83136c0dc43d6ef732402d1a1b5 (diff) | |
download | external_llvm-0de5cad74d8d2987b92b8d76af3f1eab988b3c7b.zip external_llvm-0de5cad74d8d2987b92b8d76af3f1eab988b3c7b.tar.gz external_llvm-0de5cad74d8d2987b92b8d76af3f1eab988b3c7b.tar.bz2 |
LICM does get dead instructions input to it. Instead of sinking them
out of loops, just delete them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112451 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/LICM.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 5f156db..aa842e3 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -43,6 +43,7 @@ #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/SSAUpdater.h" #include "llvm/Support/CFG.h" #include "llvm/Support/CommandLine.h" @@ -299,7 +300,7 @@ void LICM::SinkRegion(DomTreeNode *N) { // If this subregion is not in the top level loop at all, exit. if (!CurLoop->contains(BB)) return; - // We are processing blocks in reverse dfo, so process children first... + // We are processing blocks in reverse dfo, so process children first. const std::vector<DomTreeNode*> &Children = N->getChildren(); for (unsigned i = 0, e = Children.size(); i != e; ++i) SinkRegion(Children[i]); @@ -310,6 +311,16 @@ void LICM::SinkRegion(DomTreeNode *N) { for (BasicBlock::iterator II = BB->end(); II != BB->begin(); ) { Instruction &I = *--II; + + // If the instruction is dead, we would try to sink it because it isn't used + // in the loop, instead, just delete it. + if (isInstructionTriviallyDead(&I)) { + ++II; + CurAST->deleteValue(&I); + I.eraseFromParent(); + Changed = true; + continue; + } // Check to see if we can sink this instruction to the exit blocks // of the loop. We can do this if the all users of the instruction are |