aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-03-09 21:14:16 +0000
committerDan Gohman <gohman@apple.com>2009-03-09 21:14:16 +0000
commit0daeed270bb0318b8a1337026fe92646a40ee3d9 (patch)
tree589067f0029b7a4c3c4f901b2fd8d7f6602341e9
parent53f2ae268ab0e9201c0c50c28a27d451497a0371 (diff)
downloadexternal_llvm-0daeed270bb0318b8a1337026fe92646a40ee3d9.zip
external_llvm-0daeed270bb0318b8a1337026fe92646a40ee3d9.tar.gz
external_llvm-0daeed270bb0318b8a1337026fe92646a40ee3d9.tar.bz2
Use LoopInfo's getLoopLatch() instead of doing what it does manualy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66467 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index b64c689..f331215 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1599,17 +1599,12 @@ static PHINode *InsertAffinePhi(SCEVHandle Start, SCEVHandle Step,
BasicBlock *Header = L->getHeader();
BasicBlock *Preheader = L->getLoopPreheader();
+ BasicBlock *LatchBlock = L->getLoopLatch();
PHINode *PN = PHINode::Create(Start->getType(), "lsr.iv", Header->begin());
PN->addIncoming(Rewriter.expandCodeFor(Start, Preheader->getTerminator()),
Preheader);
- pred_iterator HPI = pred_begin(Header);
- assert(HPI != pred_end(Header) && "Loop with zero preds???");
- if (!L->contains(*HPI)) ++HPI;
- assert(HPI != pred_end(Header) && L->contains(*HPI) &&
- "No backedge in loop?");
-
// If the stride is negative, insert a sub instead of an add for the
// increment.
bool isNegative = isNonConstantNegative(Step);
@@ -1622,17 +1617,14 @@ static PHINode *InsertAffinePhi(SCEVHandle Start, SCEVHandle Step,
Value *StepV = Rewriter.expandCodeFor(IncAmount, Preheader->getTerminator());
if (isNegative) {
IncV = BinaryOperator::CreateSub(PN, StepV, "lsr.iv.next",
- (*HPI)->getTerminator());
+ LatchBlock->getTerminator());
} else {
IncV = BinaryOperator::CreateAdd(PN, StepV, "lsr.iv.next",
- (*HPI)->getTerminator());
+ LatchBlock->getTerminator());
}
if (!isa<ConstantInt>(StepV)) ++NumVariable;
- pred_iterator PI = pred_begin(Header);
- if (*PI == L->getLoopPreheader())
- ++PI;
- PN->addIncoming(IncV, *PI);
+ PN->addIncoming(IncV, LatchBlock);
++NumInserted;
return PN;