From 6048c2c221a39e81d8e935dfa53e2c64c35a998e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 12 Feb 2009 18:08:24 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64388 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopIndexSplit.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp') diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index f625c13d45..2bcb10849e 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/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 EBs; - L->getExitingBlocks(EBs); - if (EBs.size() != 1) + BasicBlock *ExitingBlock = L->getExitingBlock(); + if (!ExitingBlock) return false; - BranchInst *EBR = dyn_cast(EBs[0]->getTerminator()); + BranchInst *EBR = dyn_cast(ExitingBlock->getTerminator()); if (!EBR) return false; ExitCondition = dyn_cast(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); -- cgit v1.2.3