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 | 71c4144076d35bd45f8a5103357532f958de6757 (patch) | |
tree | 20cd0db7d8abc98504ad241e1a6f679b36660e91 /lib/Analysis/ScalarEvolution.cpp | |
parent | 31529c7b6c2c4c7c5c440fc0c93a43ccc7b14989 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111034 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 394e0159db..dee7a1f8d9 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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) |