aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopIndexSplit.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-09-19 00:11:01 +0000
committerDevang Patel <dpatel@apple.com>2007-09-19 00:11:01 +0000
commit84ef08bfeeb4ffdd2b5a179ae85211f7996ef6db (patch)
treeb8340b01e9fb25018bb842a9199b6d36310e8952 /lib/Transforms/Scalar/LoopIndexSplit.cpp
parent4e062e520a24df32dd4ecbf0767ed82bc648a4ba (diff)
Bail out early, before modifying anything.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index c2e9d500a9..92a6058b5a 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -542,6 +542,11 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) {
if (!safeSplitCondition(SD))
return false;
+ BasicBlock *Latch = L->getLoopLatch();
+ BranchInst *BR = dyn_cast<BranchInst>(Latch->getTerminator());
+ if (!BR)
+ return false;
+
// Update CFG.
// Replace index variable with split value in loop body. Loop body is executed
@@ -549,11 +554,7 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) {
IndVar->replaceAllUsesWith(SD.SplitValue);
// Remove Latch to Header edge.
- BasicBlock *Latch = L->getLoopLatch();
BasicBlock *LatchSucc = NULL;
- BranchInst *BR = dyn_cast<BranchInst>(Latch->getTerminator());
- if (!BR)
- return false;
Header->removePredecessor(Latch);
for (succ_iterator SI = succ_begin(Latch), E = succ_end(Latch);
SI != E; ++SI) {