aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-13 20:11:39 +0000
committerDan Gohman <gohman@apple.com>2010-08-13 20:11:39 +0000
commit71c4144076d35bd45f8a5103357532f958de6757 (patch)
tree20cd0db7d8abc98504ad241e1a6f679b36660e91 /lib/Analysis
parent31529c7b6c2c4c7c5c440fc0c93a43ccc7b14989 (diff)
downloadexternal_llvm-71c4144076d35bd45f8a5103357532f958de6757.zip
external_llvm-71c4144076d35bd45f8a5103357532f958de6757.tar.gz
external_llvm-71c4144076d35bd45f8a5103357532f958de6757.tar.bz2
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')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 394e015..dee7a1f 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)