[PATCH] D22630: Loop rotation

Aditya Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 11:39:02 PDT 2016


hiraditya marked an inline comment as done.

================
Comment at: llvm/lib/Transforms/Scalar/LoopRotation.cpp:165
@@ -209,5 +164,3 @@
 
-  // Rotate if either the loop latch does *not* exit the loop, or if the loop
-  // latch was just simplified.
-  if (L->isLoopExiting(OrigLatch) && !SimplifiedLatch)
+  if (!isSEME(OrigH, LoopLatch, DT))
     return false;
----------------
eli.friedman wrote:
> Any update on why this check is necessary, or a comment in the code about why it is necessary?
If the loop is infinite, or, if the loop-body has incoming branches from outside of region (irreducible control flow), then the loop won't be an SEME. Although I'm not sure if llvm loop-info will detect such loops in the first place. I'll investigate and let you know.

================
Comment at: llvm/lib/Transforms/Scalar/LoopRotation.cpp:319
@@ +318,3 @@
+  // Collect all nodes of the loop from header to latch.
+  BasicBlock *NewH = collectSEMEBlocks(OrigH, OrigLatch, Blocks, Exits);
+  assert(NewH);
----------------
eli.friedman wrote:
> Is it possible this will clone more code?  The trunk version would only clone the header; it looks like this will clone the whole loop body excluding the latch block?
Yes, this will clone all the exiting basic blocks excluding the latch block (starting from the header until all it finds a BB which is not exiting). This is required to expose the redundancies that could be removed as a result of cloning the loop body. Currently there is a flag to control how much we want to clone (RotationMaxSize), I can add more specific flags to control how many exiting blocks we want to copy.
In general, it would be a good idea to clone all the exiting basic blocks to expose all the redundancies.



https://reviews.llvm.org/D22630





More information about the llvm-commits mailing list