[all-commits] [llvm/llvm-project] f87e0c: [DSE] Eliminates redundant store of an exisiting v...

yurai007 via All-commits all-commits at lists.llvm.org
Thu Oct 28 07:21:54 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f87e0c68d78652aa9973e742e6c8df86fd7eee17
      https://github.com/llvm/llvm-project/commit/f87e0c68d78652aa9973e742e6c8df86fd7eee17
  Author: Dawid Jurczak <dawid_jurek at vp.pl>
  Date:   2021-10-28 (Thu, 28 Oct 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
    M llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll

  Log Message:
  -----------
  [DSE] Eliminates redundant store of an exisiting value (PR16520)

That's https://reviews.llvm.org/D90328 follow-up.

This change eliminates writes to variables where the value that is being written is already stored in the variable.
This achieves the goal by looping through all memory definitions in the current state and getting defining access from each of them.
When there is defining access where the write instruction is identical to the original instruction it will remove this redundant write.

For example:

void f() {

x = 1;
if foo() {
   x = 1;
   g();
} else {
  h();
}

}
void g();
void h();

The second x=1 will be eliminated since it is rewriting 1 to x. This pass will produce this:

void f() {

x = 1;
if foo() {
   g();
} else {
  h();
}

}
void g();
void h();

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




More information about the All-commits mailing list