[all-commits] [llvm/llvm-project] 1b24fe: [LoopInterchange] New cost model for loop interchange

CongzheUalberta via All-commits all-commits at lists.llvm.org
Thu Jun 23 13:35:34 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1b24fe34b06cd9f2337313f513a8b19f9a37c5de
      https://github.com/llvm/llvm-project/commit/1b24fe34b06cd9f2337313f513a8b19f9a37c5de
  Author: Congzhe Cao <congzhe.cao at huawei.com>
  Date:   2022-06-23 (Thu, 23 Jun 2022)

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

  Log Message:
  -----------
  [LoopInterchange] New cost model for loop interchange

This is the second attempt to land this patch.

The patch proposed to use a new cost model for loop interchange,
which is obtained from loop cache analysis.

Given a loopnest, what loop cache analysis returns is a vector of
loops [loop0, loop1, loop2, ...] where loop0 should be replaced as the
outermost loop, loop1 should be placed one more level inside, and loop2
one more level inside, etc. What loop cache analysis does is not only more
comprehensive than the current cost model, it is also a "one-shot" query
which means that we only need to query it once during the entire loop
interchange pass, which is better than the current cost model where we
query it every time we check whether it is profitable to interchange two
loops. Thus complexity is reduced, especially after D120386 where we do
more interchanges to get the globally optimal loop access pattern.

Updates made to test cases are mostly minor changes and some corrections.
One change that applies to all tests is that we added an option
`-cache-line-size=64` to the RUN lines. This is ensure that loop cache
analysis receives a valid number of cache line size for correct analysis.
Test coverage for loop interchange is not reduced.

Currently we did not completely remove the legacy cost model, but keep it
as fall-back in case the new cost model did not run successfully. This is
because currently we have some limitations in delinearization, which sometimes
makes loop cache analysis bail out. The longer term goal is to enhance
delinearization and eventually remove the legacy cost model compeletely.

Reviewed By: bmahjour, #loopoptwg

Differential Revision: https://reviews.llvm.org/D124926




More information about the All-commits mailing list