llvm-project/llvm/test/Transforms/LoopInterchange
Congzhe Cao eac3487510 [LoopInterchange] Try to achieve the most optimal access pattern after interchange
Motivated by pr43326 (https://bugs.llvm.org/show_bug.cgi?id=43326), where a slightly
modified case is as follows.

 void f(int e[10][10][10], int f[10][10][10]) {
   for (int a = 0; a < 10; a++)
     for (int b = 0; b < 10; b++)
       for (int c = 0; c < 10; c++)
         f[c][b][a] = e[c][b][a];
 }

The ideal optimal access pattern after running interchange is supposed to be the following

 void f(int e[10][10][10], int f[10][10][10]) {
   for (int c = 0;  c < 10; c++)
     for (int b = 0; b < 10; b++)
       for (int a = 0; a < 10; a++)
         f[c][b][a] = e[c][b][a];
 }

Currently loop interchange is limited to picking up the innermost loop and finding an order
that is locally optimal for it. However, the pass failed to produce the globally optimal
loop access order. For more complex examples what we get could be quite far from the
globally optimal ordering.

What is proposed in this patch is to do a "bubble-sort" fashion when doing interchange.
By comparing neighbors in `LoopList` in each iteration, we would be able to move each loop
onto a most appropriate place, hence this is an approach that tries to achieve the
globally optimal ordering.

The motivating example above is added as a test case.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D120386
2022-04-06 15:31:56 -04:00
..
call-instructions.ll
currentLimitation.ll [LoopInterchange] Remove a limitation in LoopInterchange legality 2022-01-06 15:56:32 -05:00
debuginfo.ll
inner-indvar-depend-on-outer-indvar.ll
inner-only-reductions.ll
innermost-latch-uses-values-in-middle-header.ll
interchange-flow-dep-outer.ll
interchange-insts-between-indvar.ll
interchange-no-deps.ll
interchangeable-innerloop-multiple-indvars.ll [LoopInterchange] Enable interchange with multiple inner loop indvars 2022-01-14 16:28:41 -05:00
interchangeable-outerloop-multiple-indvars.ll [LoopInterchange] Enable interchange with multiple outer loop indvars 2022-01-13 16:51:32 -05:00
interchangeable.ll [LoopInterchange] Remove a limitation in LoopInterchange legality 2022-01-06 15:56:32 -05:00
interchanged-loop-nest-3.ll
lcssa-preheader.ll [LoopInterchange] Detect output dependency of a store instruction with itself 2022-03-09 15:50:27 -05:00
lcssa.ll [LoopInterchange] Support loop interchange with floating point reductions 2022-02-06 17:04:47 -05:00
loop-interchange-optimization-remarks.ll [LoopInterchange] Remove a limitation in LoopInterchange legality 2022-01-06 15:56:32 -05:00
not-interchanged-dependencies-1.ll
not-interchanged-loop-nest-3.ll
not-interchanged-tightly-nested.ll
outer-header-jump-to-inner-latch.ll
outer-only-reductions.ll
perserve-lcssa.ll [LoopInterchange] Detect output dependency of a store instruction with itself 2022-03-09 15:50:27 -05:00
phi-ordering.ll [LoopInterchange] Try to achieve the most optimal access pattern after interchange 2022-04-06 15:31:56 -04:00
pr43176-move-to-new-latch.ll
pr43326-ideal-access-pattern.ll [LoopInterchange] Try to achieve the most optimal access pattern after interchange 2022-04-06 15:31:56 -04:00
pr43326.ll
pr43473-invalid-lcssa-phis-in-inner-exit.ll
pr43797-lcssa-for-multiple-outer-loop-blocks.ll
pr45743-move-from-inner-preheader.ll [LoopInterchange] Detect output dependency of a store instruction with itself 2022-03-09 15:50:27 -05:00
pr48212.ll
profitability.ll
reductions-across-inner-and-outer-loop.ll [LoopInterchange] Support loop interchange with floating point reductions 2022-02-06 17:04:47 -05:00
update-condbranch-duplicate-successors.ll
vector-gep-operand.ll