From 2da2bfa088e9bf344a3ae7710dea518766cc730c Mon Sep 17 00:00:00 2001 From: Michael Kuperstein Date: Thu, 16 Mar 2017 21:07:48 +0000 Subject: [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 --- llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp index b8147fcb697..ea3e37d9c59 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp @@ -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; } -- cgit v1.2.3