Improve maybe_remove_writeonly_store to do a simple DCE for defining statement
authorAndrew Pinski <apinski@marvell.com>
Sat, 16 Oct 2021 04:14:57 +0000 (04:14 +0000)
committerAndrew Pinski <apinski@marvell.com>
Thu, 21 Oct 2021 08:18:58 +0000 (08:18 +0000)
commit113860301f46d14a255bd947d18d36f917527230
treed146b49eef3628ed6b72086820c2bb089ea06421
parent36ec4a3c927bd2cc212a7f331ad842cd90eb5283
Improve maybe_remove_writeonly_store to do a simple DCE for defining statement

Instead of putting a full blow DCE after execute_fixup_cfg, it makes sense
to try to remove the defining statement for the store that is being removed.
Using simple_dce_from_worklist makes this easier, just mark the ssa_name on
the rhs side of the store (if it was one) in a bitmap and then call
simple_dce_from_worklist at the end.

gcc.dg/pr36902.c needed to be changed such that the static array was no
longer a static array but a global array.  This is because this new dce
will remove the load as it is dead. I also filed PR 102864 for the warning
on dead loads.

gcc/ChangeLog:

* tree-cfg.c (maybe_remove_writeonly_store): Add dce_ssa_names argument.
Mark the ssa-name of the rhs as one to be removed.
(execute_fixup_cfg): Update call to maybe_remove_writeonly_store.
Call simple_dce_from_worklist at the end to a simple dce.

gcc/testsuite/ChangeLog:

* gcc.dg/pr36902.c: Move buf to be a non-static variable.
gcc/testsuite/gcc.dg/pr36902.c
gcc/tree-cfg.c