aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-02-13 22:06:36 +0000
committerDevang Patel <dpatel@apple.com>2008-02-13 22:06:36 +0000
commite6c9578fa3763553cad432acfee3698ff3364200 (patch)
tree892312f16da546f870ed3382d42903ba6046b651 /lib
parentf550d41ede2d857f4805b6c43326892b9f92c875 (diff)
downloadexternal_llvm-e6c9578fa3763553cad432acfee3698ff3364200.zip
external_llvm-e6c9578fa3763553cad432acfee3698ff3364200.tar.gz
external_llvm-e6c9578fa3763553cad432acfee3698ff3364200.tar.bz2
While moving exit condition, do not drop loop latch on the floor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 2d30eb6..383415b 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -1579,17 +1579,22 @@ void LoopIndexSplit::moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
// destination.
BranchInst *ExitingBR = cast<BranchInst>(ExitingBB->getTerminator());
ExitingBR->moveBefore(CurrentBR);
- if (ExitingBR->getSuccessor(0) == ExitBB)
+ BasicBlock *OrigDestBB = NULL;
+ if (ExitingBR->getSuccessor(0) == ExitBB) {
+ OrigDestBB = ExitingBR->getSuccessor(1);
ExitingBR->setSuccessor(1, ActiveBB);
- else
+ }
+ else {
+ OrigDestBB = ExitingBR->getSuccessor(0);
ExitingBR->setSuccessor(0, ActiveBB);
+ }
// Remove split condition and current split condition branch.
SC->eraseFromParent();
CurrentBR->eraseFromParent();
- // Connect exiting block to split condition block.
- new BranchInst(CondBB, ExitingBB);
+ // Connect exiting block to original destination.
+ new BranchInst(OrigDestBB, ExitingBB);
// Update PHINodes
updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd);