[PATCH] D73129: [LoopUnrollAndJam] Correctly update LoopInfo when unroll and jam more than 2-levels loop nests.

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 16:06:16 PST 2020


Whitney added a comment.

In D73129#1843278 <https://reviews.llvm.org/D73129#1843278>, @Meinersbur wrote:

> I'd expect
>
>   #pragma unrollandjam(2)
>   for i
>     for j
>       for k
>         A[i][j][k] = 0
>
>
> to generate this:
>
>   for i +=2
>     for j
>       for k
>         A[i][j][k] = 0
>         A[i+1][j][k] = 0
>
>
> (as by the side-note by @Whitney)
>
> That is, if the jam loop is not specified, to jam the innermost by default, which is should be what you want in most cases. For some reason I was assuming LoopUnrollAndJam was rejecting this case as not-yet-implemented. Would that be an option instead of fixing a behavior that probably is not the expected effect?


That's an interesting idea. If we want to do that, we will need to modify multiple places. Mainly outermost loop needs to be partition into a list of ForeBlocks,  a list of AftBlocks, and InnermostLoopBlocks, instead of ForeBlocks, SubLoopBlocks, and AftBlocks. ForeBlocks are the block in outermost loop but outside of innermost loop, and before the innermost loop. AftBlocks are block outside of innermost loop, and not in ForeBlocks. Safety check and code generation both need to be modified accordingly. And again, we will iterate the loops from outer to inner. Maybe we can simplify the transformation by only considering perfect nest? What does everyone think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73129





More information about the llvm-commits mailing list