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

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 30 19:18:34 PDT 2022


congzhe updated this revision to Diff 433004.
congzhe added a comment.
Herald added a subscriber: jsji.

Thanks Bardia for the comments, I've addressed them accordingly.

Regarding `test/Transforms/LICM/lnicm.ll`: the load of `z` is indeed moved out by both LICM and LNICM so there is no functional problems. The reason why the `CHECK` lines are changed here is that the new basic blocks I added in this patch (for ease of delinearization) will be involved in transformation of loop interchange, which is not the case before this patch.

With this patch:

- With LICM the load of `z` is hoisted into `entry` and since loop interchange won't take place, the load of `z` stays in `entry`.
- With LNICM the load of `z` is again hoisted into `entry`, and since `entry` is the preheader of the original outer loop, after interchange load of `z` is moved into `for.body3.preheader`, which is the new outer loop preheader.  I tried to modify the IR aiming at keep the `CHECK-NEXT` lines that you mentioned like before, but I have not been successful.

Before this patch:

For the original `test/Transforms/LICM/lnicm.ll` before this patch, the `entry` block is not considered part of the loop (and a new outer preheader `for.body.preheader` will be generated) so once the load of `z` is hoisted to `entry` by either LICM or LNICM, it would always stay there since `entry` was not involved in transformation of loop interchange.


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

https://reviews.llvm.org/D124926

Files:
  llvm/lib/Transforms/Scalar/LoopInterchange.cpp
  llvm/test/Transforms/LICM/lnicm.ll
  llvm/test/Transforms/LoopInterchange/call-instructions.ll
  llvm/test/Transforms/LoopInterchange/currentLimitation.ll
  llvm/test/Transforms/LoopInterchange/debuginfo.ll
  llvm/test/Transforms/LoopInterchange/inner-indvar-depend-on-outer-indvar.ll
  llvm/test/Transforms/LoopInterchange/inner-only-reductions.ll
  llvm/test/Transforms/LoopInterchange/innermost-latch-uses-values-in-middle-header.ll
  llvm/test/Transforms/LoopInterchange/interchange-flow-dep-outer.ll
  llvm/test/Transforms/LoopInterchange/interchange-insts-between-indvar.ll
  llvm/test/Transforms/LoopInterchange/interchange-no-deps.ll
  llvm/test/Transforms/LoopInterchange/interchangeable-innerloop-multiple-indvars.ll
  llvm/test/Transforms/LoopInterchange/interchangeable-outerloop-multiple-indvars.ll
  llvm/test/Transforms/LoopInterchange/interchangeable.ll
  llvm/test/Transforms/LoopInterchange/interchanged-loop-nest-3.ll
  llvm/test/Transforms/LoopInterchange/lcssa-preheader.ll
  llvm/test/Transforms/LoopInterchange/lcssa.ll
  llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll
  llvm/test/Transforms/LoopInterchange/not-interchanged-dependencies-1.ll
  llvm/test/Transforms/LoopInterchange/not-interchanged-loop-nest-3.ll
  llvm/test/Transforms/LoopInterchange/not-interchanged-tightly-nested.ll
  llvm/test/Transforms/LoopInterchange/outer-header-jump-to-inner-latch.ll
  llvm/test/Transforms/LoopInterchange/outer-only-reductions.ll
  llvm/test/Transforms/LoopInterchange/perserve-lcssa.ll
  llvm/test/Transforms/LoopInterchange/pr43176-move-to-new-latch.ll
  llvm/test/Transforms/LoopInterchange/pr43326-ideal-access-pattern.ll
  llvm/test/Transforms/LoopInterchange/pr43326.ll
  llvm/test/Transforms/LoopInterchange/pr43473-invalid-lcssa-phis-in-inner-exit.ll
  llvm/test/Transforms/LoopInterchange/pr43797-lcssa-for-multiple-outer-loop-blocks.ll
  llvm/test/Transforms/LoopInterchange/pr45743-move-from-inner-preheader.ll
  llvm/test/Transforms/LoopInterchange/pr48212.ll
  llvm/test/Transforms/LoopInterchange/profitability.ll
  llvm/test/Transforms/LoopInterchange/reductions-across-inner-and-outer-loop.ll
  llvm/test/Transforms/LoopInterchange/update-condbranch-duplicate-successors.ll
  llvm/test/Transforms/LoopInterchange/vector-gep-operand.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124926.433004.patch
Type: text/x-patch
Size: 42851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220531/0bad4829/attachment-0001.bin>


More information about the llvm-commits mailing list