summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-15 01:25:43 +0000
committerDan Gohman <gohman@apple.com>2009-07-15 01:25:43 +0000
commitc43e47938aaf3890f8f62201ff65897e85239d53 (patch)
treee027487c3e7253f89a1ee7c8aae7465f46c63201 /llvm/lib/Analysis/LoopInfo.cpp
parent7f318128d0367f4e7c38b10f33ae5ef5127aeac4 (diff)
downloadbcm5719-llvm-c43e47938aaf3890f8f62201ff65897e85239d53.tar.gz
bcm5719-llvm-c43e47938aaf3890f8f62201ff65897e85239d53.zip
Make makeLoopInvariant report whether it made any changes or not,
and use this to simplify more code. llvm-svn: 75722
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index fb8027c14fd..63de1aa7aee 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -58,9 +58,10 @@ bool Loop::isLoopInvariant(Instruction *I) const {
/// If InsertPt is specified, it is the point to hoist instructions to.
/// If null, the terminator of the loop preheader is used.
///
-bool Loop::makeLoopInvariant(Value *V, Instruction *InsertPt) const {
+bool Loop::makeLoopInvariant(Value *V, bool &Changed,
+ Instruction *InsertPt) const {
if (Instruction *I = dyn_cast<Instruction>(V))
- return makeLoopInvariant(I);
+ return makeLoopInvariant(I, Changed, InsertPt);
return true; // All non-instructions are loop-invariant.
}
@@ -73,7 +74,8 @@ bool Loop::makeLoopInvariant(Value *V, Instruction *InsertPt) const {
/// If InsertPt is specified, it is the point to hoist instructions to.
/// If null, the terminator of the loop preheader is used.
///
-bool Loop::makeLoopInvariant(Instruction *I, Instruction *InsertPt) const {
+bool Loop::makeLoopInvariant(Instruction *I, bool &Changed,
+ Instruction *InsertPt) const {
// Test if the value is already loop-invariant.
if (isLoopInvariant(I))
return true;
@@ -96,10 +98,11 @@ bool Loop::makeLoopInvariant(Instruction *I, Instruction *InsertPt) const {
}
// Don't hoist instructions with loop-variant operands.
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (!makeLoopInvariant(I->getOperand(i), InsertPt))
+ if (!makeLoopInvariant(I->getOperand(i), Changed, InsertPt))
return false;
// Hoist.
I->moveBefore(InsertPt);
+ Changed = true;
return true;
}
OpenPOWER on IntegriCloud