[llvm-commits] [llvm] r64763 - in /llvm/branches/Apple/Dib: include/llvm/Analysis/LoopInfo.h lib/Transforms/Scalar/LoopIndexSplit.cpp
Bill Wendling
isanbard at gmail.com
Tue Feb 17 05:50:57 PST 2009
Author: void
Date: Tue Feb 17 07:50:55 2009
New Revision: 64763
URL: http://llvm.org/viewvc/llvm-project?rev=64763&view=rev
Log:
Pull r64388 into Dib:
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.
Modified:
llvm/branches/Apple/Dib/include/llvm/Analysis/LoopInfo.h
llvm/branches/Apple/Dib/lib/Transforms/Scalar/LoopIndexSplit.cpp
Modified: llvm/branches/Apple/Dib/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/Analysis/LoopInfo.h?rev=64763&r1=64762&r2=64763&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/Analysis/LoopInfo.h Tue Feb 17 07:50:55 2009
@@ -185,6 +185,16 @@
}
}
+ /// getExitingBlock - If getExitingBlocks would return exactly one block,
+ /// return that block. Otherwise return null.
+ BlockT *getExitingBlock() const {
+ SmallVector<BlockT*, 8> ExitingBlocks;
+ getExitingBlocks(ExitingBlocks);
+ if (ExitingBlocks.size() == 1)
+ return ExitingBlocks[0];
+ return 0;
+ }
+
/// getExitBlocks - Return all of the successor blocks of this loop. These
/// are the blocks _outside of the current loop_ which are branched to.
///
Modified: llvm/branches/Apple/Dib/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=64763&r1=64762&r2=64763&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Transforms/Scalar/LoopIndexSplit.cpp Tue Feb 17 07:50:55 2009
@@ -236,15 +236,14 @@
}
// 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);
More information about the llvm-commits
mailing list