This is a better patch to fix PR 117096 (phiopt vs clobbers).
The only time we remove clobbers of local variables is during
remove_unused_locals. Since DSE might remove all of the stores
to a local variable, it makes sense to also try to remove unused local
variables afterwards.
This shows up more in C++ code with encapsulation.

This was previously mentioned to be done:
https://gcc.gnu.org/pipermail/gcc-patches/2021-April/567744.html
In the end it was chosen "Or we might want to place explicit schedules of
remove_unused_locals in the pass pipeline." (in stdargs,
https://gcc.gnu.org/pipermail/gcc-patches/2021-April/568807.html) but that is 
too
late for early phiopt. This patch does the "maybe we should unconditionally do 
so"
option instead.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

        PR tree-optimization/117096
        * tree-ssa-dse.cc (pass_data_dse): Add TODO_remove_unused_locals
        to todo_flags_finish.

Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
---
 gcc/tree-ssa-dse.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc
index 63bf4491cf6..42a133b8631 100644
--- a/gcc/tree-ssa-dse.cc
+++ b/gcc/tree-ssa-dse.cc
@@ -1654,7 +1654,7 @@ const pass_data pass_data_dse =
   0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
-  0, /* todo_flags_finish */
+  TODO_remove_unused_locals, /* todo_flags_finish */
 };
 
 class pass_dse : public gimple_opt_pass
-- 
2.43.0

Reply via email to