diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-13 20:11:39 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-13 20:11:39 +0000 |
commit | ec0120a1238de988d65cf1be399953e3647eb5b9 (patch) | |
tree | 4f3f8fe5937ab6ee51d1234d39b14325ff7a8c62 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 5af43f04dcfe39090f6c190ef86bbe40b1644355 (diff) | |
download | bcm5719-llvm-ec0120a1238de988d65cf1be399953e3647eb5b9.tar.gz bcm5719-llvm-ec0120a1238de988d65cf1be399953e3647eb5b9.zip |
An add recurrence is loop-invariant in any loop inside of its
associated loop. This avoids potentially expensive traversals
of the add recurrence's operands.
llvm-svn: 111034
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 394e0159db8..dee7a1f8d93 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -303,6 +303,10 @@ bool SCEVAddRecExpr::isLoopInvariant(const Loop *QueryLoop) const { if (QueryLoop->contains(L)) return false; + // This recurrence is invariant w.r.t. QueryLoop if L contains QueryLoop. + if (L->contains(QueryLoop)) + return true; + // This recurrence is variant w.r.t. QueryLoop if any of its operands // are variant. for (unsigned i = 0, e = getNumOperands(); i != e; ++i) |