[PATCH] D124926: [LoopInterchange] New cost model for loop interchange

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 11:58:30 PDT 2022


congzhe added a comment.

In D124926#3718761 <https://reviews.llvm.org/D124926#3718761>, @uabelho wrote:

> Hello,
>
> We stumbled upon a case where loop-interchange seems to start hanging and consume more and more memory until it cannot do that any longer with this patch:
>
>   opt -passes="loop(loop-interchange,loop-interchange)" bbi-72548.ll -o /dev/null
>
> F24115392: bbi-72548.ll <https://reviews.llvm.org/F24115392>

Hi Mikael, thanks for this. I've quickly looked at it and the problem can be avoided by running `opt -passes="loop(loop-interchange),loop(loop-interchange))" bbi-72548.ll -o /dev/null` using the new pass manager, or `opt -loop-interchange -loop-interchange" bbi-72548.ll -o /dev/null` using the legacy pass manager.

My impression is that the root cause is not within this patch but I suspect it is a problem with the loopnest pass pipeline within the new pass manager. This IR is a triply-nested loop, after the first interchange pass, it should still be a triply-nested loop. However, when running `opt -passes="loop(loop-interchange,loop-interchange)`, what is populated into the loopnest data structure in the `LoopInterchangePass::run()` function at the beginning of the 2nd interchange pass is a 2-level (doubly-nested) loop. This is incorrect and caused the trouble (infinitely looping over the following code in `LoopInterchange.cpp`).

  while (Dep.size() != Level) {
    Dep.push_back('I');
  }

Seems like the loopnest pass pipeline does not get the loop correct, when the loop is modified during the pipeline.

When running `opt -passes="loop(loop-interchange),loop(loop-interchange))" bbi-72548.ll -o /dev/null` or `opt -loop-interchange -loop-interchange" bbi-72548.ll -o /dev/null`, what is populated into the loopnest data structure in the `LoopInterchangePass::run()` function at the beginning of the 2nd interchange pass is a 3-level (triply-nested) loop, which is correct.

I'll do more investigations and post updates here.


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

https://reviews.llvm.org/D124926



More information about the llvm-commits mailing list