]> granicus.if.org Git - llvm/commitdiff
[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops
authorAnna Thomas <anna@azul.com>
Wed, 3 May 2017 17:43:59 +0000 (17:43 +0000)
committerAnna Thomas <anna@azul.com>
Wed, 3 May 2017 17:43:59 +0000 (17:43 +0000)
Summary:
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

Reviewers: davide

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302058 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LoopUnrollRuntime.cpp

index 85db734fb182755cda9ea1025a5f01c3c58b5cfb..305b87ea287d59f4afb8c86e4be2df11cf96f5d5 100644 (file)
@@ -512,6 +512,13 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
 
   BasicBlock *Latch = L->getLoopLatch();
 
+  // Cloning the loop basic blocks (`CloneLoopBlocks`) 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!");
   // Loop structure is the following:
   //
   // PreHeader