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
This commit is contained in:
Dan Gohman 2010-08-13 20:11:39 +00:00
parent 31529c7b6c
commit 71c4144076

View File

@ -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)