[PATCH] D75013: [LoopTerminology] Rotated Loops

Stefanos Baziotis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 23 16:01:50 PST 2020


baziotis marked an inline comment as done.
baziotis added inline comments.


================
Comment at: llvm/docs/LoopTerminology.rst:161-163
+Loops are rotated by the loop-rotate pass. The purpose
+of this transformation is to convert loops into
+do/while style loops. Example:
----------------
Meinersbur wrote:
> baziotis wrote:
> > Meinersbur wrote:
> > > Converting to do/while style is a description of loop-rotation. One of the purposes is to allow hoisting invariant loads into the preheader. In non-rotated loops, a load in the preaheader would be executed even if the memory was never accessed in the original loop.
> > Oh, because you might do no iterations at all right? So, with the do-while, you'll do at least once. Regarding the wording, is this better?
> > "Loops are rotated by the loop-rotate pass, which converts loops into do/while style loops."
> > Then follow with examples and then mention the purposes. Also, should I add to the purposes that a latch block is an exiting block (and that this is useful to loop fusion) ? Although, as I stated in the comment, I have not completely understood this part with the latch.
> Yes, it is better.
> 
> The latch being also an exiting block is kind-of the definition of loop rotation: the latch contains the condition on whether to execute another iteration or leave the loop, i.e. the condition if the `do` part of a while/do loop.
> ```
>   /// Return true if the loop is in rotated form.
>   ///
>   /// This does not check if the loop was rotated by loop rotation, instead it
>   /// only checks if the loop is in rotated form (has a valid latch that exists
>   /// the loop).
>   bool isRotatedForm() const {
>     assert(!isInvalid() && "Loop not in a valid state!");
>     BasicBlock *Latch = getLoopLatch();
>     return Latch && isLoopExiting(Latch);
>   }
> ```
Ok, thanks! I won't put it then.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75013/new/

https://reviews.llvm.org/D75013





More information about the llvm-commits mailing list