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 | 701a4aef7fa0ece4dc1fdbc88b981820564cb4e4 (patch) | |
tree | 42e8019595b982abefb76583f62dfa37bda9cbab /lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | 4038f9c21b17378617c25f3092fe615326f8b874 (diff) |
When expanding expressions which are using post-inc mode for multiple loops,
ensure that the expansion is dominated by the increments of those loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 631092b326..6eaa93d2aa 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/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. |