[PATCH] D144226: Allow inner-loop only reductions

Ankit via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 15:30:38 PST 2023


quic_aankit created this revision.
quic_aankit added reviewers: fhahn, efriedma.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
quic_aankit requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

  Motivating example:
  
      for (j = 0; j < n; j++) {
          for (k = 0; k < l; k++) {
              z[j] += x[k]*y[n*k+j];
          }
      }
  
  In the code above we should be able to use LoopInterchange to interchange the
  j and k loop as it allows the innermost loop to be vectorized. However in the
  current state the LICM promotes z[j] to scalar effective changing the code to:
  
      for (j = 0; j < n; j++) {
          int tmp = z[j];
          for (k = 0; k < l; k++) {
              tmp += x[k]*y[n*k+j];
          }
          z[j] = tmp;
      }
  
  After LICM the loops are not tightly nested and hence LoopInterchange cannot
  work.
  
  The patch aims to look for removablePHIs in the InnerLoop Header
  and sink the load and hoist store of LICM promoted variables if they
  help in loop-interchange.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144226

Files:
  llvm/lib/Transforms/Scalar/LoopInterchange.cpp
  llvm/test/Transforms/LoopInterchange/inner-only-reductions.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144226.498171.patch
Type: text/x-patch
Size: 31332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/342b8f99/attachment-0001.bin>


More information about the llvm-commits mailing list