[LoopUnroll] Don't peel loops where the latch isn't the exiting block

Peeling assumed this doesn't happen, but didn't check it.
This fixes PR32178.

Differential Revision: https://reviews.llvm.org/D30757

llvm-svn: 297993
This commit is contained in:
Michael Kuperstein
2017-03-16 21:07:48 +00:00
parent 99de88d1f3
commit 2da2bfa088
2 changed files with 43 additions and 0 deletions

View File

@@ -56,6 +56,13 @@ static bool canPeel(Loop *L) {
if (!L->getExitingBlock() || !L->getUniqueExitBlock())
return false;
// Don't try to peel loops where the latch is not the exiting block.
// This can be an indication of two different things:
// 1) The loop is not rotated.
// 2) The loop contains irreducible control flow that involves the latch.
if (L->getLoopLatch() != L->getExitingBlock())
return false;
return true;
}