[PATCH] D53027: [LoopInterchange] Fix inner loop reduction handling.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 9 10:17:21 PDT 2018


fhahn created this revision.
fhahn added reviewers: efriedma, mcrosier, davide.

Currently, LoopInterchange generates wrong code for inner loop only
reductions that do not have a promoted load & store in the outer loop,
e.g something like:

  for (unsigned i = 0; i < 100; i++) {
    y = 0;
    for (unsigned j = 0; j < 100; j++) {
      y += A[i][j];
    }
  }

This patch tries to detect valid inner loop only reductions, by checking
the incoming value to an inner loop reduction (it needs to be a load in
the inner loop preheader) and the inner loop reduction result has to be
stored to the same location in the inner loop exit block.

Unfortunately, the detection is slightly more complex than I would like,
but LCSSA forces us to look through additional PHIs.

An alternative would be to drop support for inner loop only reductions.
For the test-suite, there is only a single loop that gets interchanged
with such a reduction.


https://reviews.llvm.org/D53027

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53027.168822.patch
Type: text/x-patch
Size: 35879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181009/6d79b08c/attachment.bin>


More information about the llvm-commits mailing list