[PATCH] D90328: Eliminates dead store of an exisiting value

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 2 07:28:24 PST 2020


lebedev.ri added a comment.

Terminology check: the store being eliminated isn't so much dead,
it's that the stored value is identical to the currently-stored value,
i.e. the store is effectively a no-op.

Just to check, there is a test for the following:

  int data;
  data = 0; // keep
  data = 0; // eliminate
  data = 1; // keep
  data = 0; // DON'T eliminate, since last stored value is 1.
  data = 0; // eliminate
  data = 1; // keep
  data = 1; // eliminate

?



================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:2392-2393
+                         "already exisiting value\n");
+    for (int I = MemDefs.size() - 1; I >= 0; I--) {
+      MemoryDef *Def = MemDefs[I];
+      if (SkipStores.find(Def) != SkipStores.end() ||
----------------



================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:2403-2405
+      for (auto UI = DefAccess->use_begin(), IE = DefAccess->use_end();
+           UI != IE;) {
+        MemoryAccess *UseAccess = cast<MemoryAccess>((UI++)->getUser());
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90328/new/

https://reviews.llvm.org/D90328



More information about the llvm-commits mailing list