summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 917d1119dc6..dd477e80069 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -1968,21 +1968,22 @@ bool LoopIdiomRecognize::recognizeBCmpLoopControlFlow(
if (CmpLoop.LatchBrContinueBB != LoopHeaderBB)
std::swap(CmpLoop.LatchBrFinishBB, CmpLoop.LatchBrContinueBB);
+ SmallVector<BasicBlock *, 2> ExitBlocks;
+
+ CurLoop->getUniqueExitBlocks(ExitBlocks);
+ assert(ExitBlocks.size() <= 2U && "Can't have more than two exit blocks.");
+
// Check that control-flow between blocks is as expected.
if (CmpLoop.HeaderBrEqualBB != LoopLatchBB ||
- CmpLoop.LatchBrContinueBB != LoopHeaderBB) {
+ CmpLoop.LatchBrContinueBB != LoopHeaderBB ||
+ !is_contained(ExitBlocks, CmpLoop.HeaderBrUnequalBB) ||
+ !is_contained(ExitBlocks, CmpLoop.LatchBrFinishBB)) {
LLVM_DEBUG(dbgs() << "Loop control-flow not recognized.\n");
return false;
}
- SmallVector<BasicBlock *, 2> ExitBlocks;
- CurLoop->getUniqueExitBlocks(ExitBlocks);
- assert(ExitBlocks.size() <= 2U && "Can't have more than two exit blocks.");
-
assert(!is_contained(ExitBlocks, CmpLoop.HeaderBrEqualBB) &&
- is_contained(ExitBlocks, CmpLoop.HeaderBrUnequalBB) &&
!is_contained(ExitBlocks, CmpLoop.LatchBrContinueBB) &&
- is_contained(ExitBlocks, CmpLoop.LatchBrFinishBB) &&
"Unexpected exit edges.");
LLVM_DEBUG(dbgs() << "Recognized loop control-flow.\n");
OpenPOWER on IntegriCloud