diff options
author | Whitney Tsang <whitney.uwaterloo@gmail.com> | 2019-09-26 20:20:42 +0000 |
---|---|---|
committer | Whitney Tsang <whitney.uwaterloo@gmail.com> | 2019-09-26 20:20:42 +0000 |
commit | 9c5fbcf9206d46e9226ca3168e7580d96d7609f0 (patch) | |
tree | c2c22f87871b838252a808959f1cc6c603a06d4d /llvm/lib/Analysis/LoopInfo.cpp | |
parent | 1202614d16e894f244e9f9afd391b1445c7a96c4 (diff) | |
download | bcm5719-llvm-9c5fbcf9206d46e9226ca3168e7580d96d7609f0.tar.gz bcm5719-llvm-9c5fbcf9206d46e9226ca3168e7580d96d7609f0.zip |
[LOOPGUARD] Disable loop with multiple loop exiting blocks.
Summary: As discussed in the loop group meeting. With the current
definition of loop guard, we should not allow multiple loop exiting
blocks. For loops that has multiple loop exiting blocks, we can simply
unable to find the loop guard.
When getUniqueExitBlock() obtains a vector size not equals to one, that
means there is either no exit blocks or there exists more than one
unique block the loop exit to.
If we don't disallow loop with multiple loop exit blocks, then with our
current implementation, there can exist exit blocks don't post dominated
by the non pre-header successor of the guard block.
Reviewer: reames, Meinersbur, kbarton, etiotto, bmahjour
Reviewed By: Meinersbur, kbarton
Subscribers: fhahn, hiraditya, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D66529
llvm-svn: 373011
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 5d481a4131a..c37a5c48e50 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -369,18 +369,16 @@ bool Loop::isAuxiliaryInductionVariable(PHINode &AuxIndVar, BranchInst *Loop::getLoopGuardBranch() const { assert(isLoopSimplifyForm() && "Only valid for loop in simplify form"); BasicBlock *Preheader = getLoopPreheader(); - BasicBlock *Latch = getLoopLatch(); - assert(Preheader && Latch && + assert(Preheader && getLoopLatch() && "Expecting a loop with valid preheader and latch"); - assert(isLoopExiting(Latch) && "Only valid for rotated loop"); + assert(isLoopExiting(getLoopLatch()) && "Only valid for rotated loop"); - Instruction *LatchTI = Latch->getTerminator(); - if (!LatchTI || LatchTI->getNumSuccessors() != 2) + // Disallow loops with more than one unique exit block, as we do not verify + // that GuardOtherSucc post dominates all exit blocks. + BasicBlock *ExitFromLatch = getUniqueExitBlock(); + if (!ExitFromLatch) return nullptr; - BasicBlock *ExitFromLatch = (LatchTI->getSuccessor(0) == getHeader()) - ? LatchTI->getSuccessor(1) - : LatchTI->getSuccessor(0); BasicBlock *ExitFromLatchSucc = ExitFromLatch->getUniqueSuccessor(); if (!ExitFromLatchSucc) return nullptr; |