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.