diff options
author | Dan Gohman <gohman@apple.com> | 2010-04-08 05:57:57 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-04-08 05:57:57 +0000 |
commit | 4506539d84095e766c91ef9aa0517435eb6bc3de (patch) | |
tree | a8c0513716db69a0f003fcd0fd94aca3f711e4cc /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | 8ee6760971085f63258bca2777da61adfe446afe (diff) | |
download | bcm5719-llvm-4506539d84095e766c91ef9aa0517435eb6bc3de.tar.gz bcm5719-llvm-4506539d84095e766c91ef9aa0517435eb6bc3de.zip |
When expanding expressions which are using post-inc mode for multiple loops,
ensure that the expansion is dominated by the increments of those loops.
llvm-svn: 100748
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 631092b3260..6eaa93d2aa0 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2820,6 +2820,22 @@ Value *LSRInstance::Expand(const LSRFixup &LF, else Inputs.push_back(IVIncInsertPos); } + // The expansion must also be dominated by the increment positions of any + // loops it for which it is using post-inc mode. + for (PostIncLoopSet::const_iterator I = LF.PostIncLoops.begin(), + E = LF.PostIncLoops.end(); I != E; ++I) { + const Loop *PIL = *I; + if (PIL == L) continue; + + SmallVector<BasicBlock *, 4> ExitingBlocks; + PIL->getExitingBlocks(ExitingBlocks); + if (!ExitingBlocks.empty()) { + BasicBlock *BB = ExitingBlocks[0]; + for (unsigned i = 1, e = ExitingBlocks.size(); i != e; ++i) + BB = DT.findNearestCommonDominator(BB, ExitingBlocks[i]); + Inputs.push_back(BB->getTerminator()); + } + } // Then, climb up the immediate dominator tree as far as we can go while // still being dominated by the input positions. |