[PATCH] D32801: [RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 06:36:54 PDT 2017


anna created this revision.

Cloning basic blocks in the loop for runtime loop unroller depends on loop being
in rotated form (i.e. loop latch target is the exit block). 
Assert that this is true, so that callers of runtime loop unroller pass in
canonical loops.
The single caller of this function has that check recently added:
https://reviews.llvm.org/rL301239


https://reviews.llvm.org/D32801

Files:
  lib/Transforms/Utils/LoopUnrollRuntime.cpp


Index: lib/Transforms/Utils/LoopUnrollRuntime.cpp
===================================================================
--- lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -640,6 +640,13 @@
   // iterations. This function adds the appropriate CFG connections.
   BasicBlock *InsertBot = UseEpilogRemainder ? Exit : PrologExit;
   BasicBlock *InsertTop = UseEpilogRemainder ? EpilogPreHeader : PrologPreHeader;
+  // Cloning the loop basic blocks requires that one of the targets of the Latch
+  // be the (single) exit block out of the loop. This needs to be guaranteed by
+  // the callers of UnrollRuntimeLoopRemainder.
+  BranchInst *LatchBR = cast<BranchInst>(Latch->getTerminator());
+  assert(LatchBR->getSuccessor(0) == Exit ||
+         LatchBR->getSuccessor(1) == Exit && "loop latch successor should be "
+                                             "exit block!");
   CloneLoopBlocks(L, ModVal, CreateRemainderLoop, UseEpilogRemainder, InsertTop,
                   InsertBot, NewPreHeader, NewBlocks, LoopBlocks, VMap, DT, LI);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32801.97625.patch
Type: text/x-patch
Size: 1086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170503/45bfb475/attachment.bin>


More information about the llvm-commits mailing list