diff options
author | Dan Gohman <gohman@apple.com> | 2009-02-12 18:08:24 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-02-12 18:08:24 +0000 |
commit | 656b097b8a07365e8465d224f21d6c6beabd0be9 (patch) | |
tree | 643ed187009765fa270955e71070dc3332d373c4 /llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | |
parent | 6a60fa2428fa521cc9bbfc84d176e91389449460 (diff) | |
download | bcm5719-llvm-656b097b8a07365e8465d224f21d6c6beabd0be9.tar.gz bcm5719-llvm-656b097b8a07365e8465d224f21d6c6beabd0be9.zip |
Add a utility function to LoopInfo to return the exit block
when the loop has exactly one exit, and make use of it in
LoopIndexSplit.
llvm-svn: 64388
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index f625c13d453..2bcb10849ed 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -236,15 +236,14 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { } // Reject loop if loop exit condition is not suitable. - SmallVector<BasicBlock *, 2> EBs; - L->getExitingBlocks(EBs); - if (EBs.size() != 1) + BasicBlock *ExitingBlock = L->getExitingBlock(); + if (!ExitingBlock) return false; - BranchInst *EBR = dyn_cast<BranchInst>(EBs[0]->getTerminator()); + BranchInst *EBR = dyn_cast<BranchInst>(ExitingBlock->getTerminator()); if (!EBR) return false; ExitCondition = dyn_cast<ICmpInst>(EBR->getCondition()); if (!ExitCondition) return false; - if (EBs[0] != L->getLoopLatch()) return false; + if (ExitingBlock != L->getLoopLatch()) return false; IVExitValue = ExitCondition->getOperand(1); if (!L->isLoopInvariant(IVExitValue)) IVExitValue = ExitCondition->getOperand(0); |