[llvm-commits] [llvm] r74338 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Dan Gohman
gohman at apple.com
Fri Jun 26 15:17:22 PDT 2009
Author: djg
Date: Fri Jun 26 17:17:21 2009
New Revision: 74338
URL: http://llvm.org/viewvc/llvm-project?rev=74338&view=rev
Log:
Fix SCEVAddRecExpr::isLoopInvariant to test if all of its operands
are loop invariant, not just the start operand.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=74338&r1=74337&r2=74338&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Jun 26 17:17:21 2009
@@ -327,12 +327,22 @@
bool SCEVAddRecExpr::isLoopInvariant(const Loop *QueryLoop) const {
- // This recurrence is invariant w.r.t to QueryLoop iff QueryLoop doesn't
- // contain L and if the start is invariant.
// Add recurrences are never invariant in the function-body (null loop).
- return QueryLoop &&
- !QueryLoop->contains(L->getHeader()) &&
- getOperand(0)->isLoopInvariant(QueryLoop);
+ if (!QueryLoop)
+ return false;
+
+ // This recurrence is variant w.r.t. QueryLoop if QueryLoop contains L.
+ if (QueryLoop->contains(L->getHeader()))
+ return false;
+
+ // This recurrence is variant w.r.t. QueryLoop if any of its operands
+ // are variant.
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
+ if (!getOperand(i)->isLoopInvariant(QueryLoop))
+ return false;
+
+ // Otherwise it's loop-invariant.
+ return true;
}
More information about the llvm-commits
mailing list