https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102864
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:113860301f46d14a255bd947d18d36f917527230 commit r12-4598-g113860301f46d14a255bd947d18d36f917527230 Author: Andrew Pinski <apin...@marvell.com> Date: Sat Oct 16 04:14:57 2021 +0000 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.