[PATCH] D100464: [DSE] Remove stores in the same loop iteration

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 14 04:15:49 PDT 2021


dmgreen created this revision.
dmgreen added reviewers: fhahn, asbirlea, nikic, hfinkel.
Herald added subscribers: kerbowa, george.burgess.iv, hiraditya, kristof.beyls, Prazek, nhaehnle, jvesely.
dmgreen requested review of this revision.
Herald added a project: LLVM.

DSE will currently only remove stores in the same block unless they can be guaranteed to be loop invariant. This expands that to any stores that are in the same Loop, at the same loop level. I believe this should still account for where AA/MSSA will not handle aliasing between loops, but allow the dead stores to be removed where they overlap in the same loop iteration. It requires adding loop info to DSE, but that looks fairly harmless.

The test case this helps is from code like this, which can come up in certain matrix operations:

    for(i=..)
      dst[i] = 0;
      for(j=..)
  	  dst[i] += src[i*n+j];

After LICM, this becomes:

  for(i=..)
    dst[i] = 0;
    sum = 0;
    for(j=..)
      sum += src[i*n+j];
    dst[i] = sum;

The first store is dead, but is not currently removed.


https://reviews.llvm.org/D100464

Files:
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Transforms/DeadStoreElimination/multiblock-loops.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100464.337391.patch
Type: text/x-patch
Size: 8362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210414/4199c762/attachment.bin>


More information about the llvm-commits mailing list