From 30ffb6fcb643b121543a67acc8e5f772a17b0d23 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sun, 4 Oct 2015 14:53:18 +0000 Subject: [PATCH] [FIX] Check loop latches for valid control too. This patch cannot be tested on its own as the isValidCFG currently hides the fact that control is actually non-affine with over-approximation. This will be corrected in the next patch and a test for non-affine latches will be added. llvm-svn: 249272 --- polly/lib/Analysis/ScopDetection.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 354c925aceb6..01355e7ce6ef 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -729,12 +729,13 @@ bool ScopDetection::isValidInstruction(Instruction &Inst, bool ScopDetection::canUseISLTripCount(Loop *L, DetectionContext &Context) const { - // Ensure the loop has valid exiting blocks, otherwise we need to - // overapproximate it as a boxed loop. - SmallVector ExitingBlocks; - L->getExitingBlocks(ExitingBlocks); - for (BasicBlock *ExitingBB : ExitingBlocks) { - if (!isValidCFG(*ExitingBB, Context)) + // Ensure the loop has valid exiting blocks as well as latches, otherwise we + // need to overapproximate it as a boxed loop. + SmallVector LoopControlBlocks; + L->getLoopLatches(LoopControlBlocks); + L->getExitingBlocks(LoopControlBlocks); + for (BasicBlock *ControlBB : LoopControlBlocks) { + if (!isValidCFG(*ControlBB, Context)) return false; }