[llvm] r302058 - [RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops

Anna Thomas via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 12:29:21 PDT 2017


thanks, I was going to move the LatchBr inside the assert, and perhaps the compiler would common the 2 instances up in fastdebug/debug builds.

I’ll follow your idea.


Anna
On May 3, 2017, at 3:25 PM, Davide Italiano <davide at freebsd.org<mailto:davide at freebsd.org>> wrote:

On Wed, May 3, 2017 at 12:19 PM, Craig Topper via llvm-commits
<llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
The variable LatchBR is unused in Release builds and throws a warning.

~Craig


Adding (void)LatchBr; immediately after the use should fix the warning
as the variable is only used inside the assert.
This is how we fix these cases, FWIW.

On Wed, May 3, 2017 at 10:44 AM, Anna Thomas via llvm-commits
<llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:

Author: annat
Date: Wed May  3 12:43:59 2017
New Revision: 302058

URL: http://llvm.org/viewvc/llvm-project?rev=302058&view=rev
Log:
[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops

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

Modified:
   llvm/trunk/lib/Transforms/Utils/LoopUnrollRuntime.cpp

Modified: llvm/trunk/lib/Transforms/Utils/LoopUnrollRuntime.cpp
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnrollRuntime.cpp?rev=302058&r1=302057&r2=302058&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnrollRuntime.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnrollRuntime.cpp Wed May  3
12:43:59 2017
@@ -512,6 +512,13 @@ bool llvm::UnrollRuntimeLoopRemainder(Lo

  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


_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


--
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170503/bf4c9e08/attachment.html>


More information about the llvm-commits mailing list