aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-08-23 13:44:29 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-08-23 14:37:27 +0200
commitde1923f9f4d5344694c22ca883aeb15caf635734 (patch)
tree60860333f45e74e01768249af3693af209623b03 /gcc
parenta35dd276cbf6236e08bcf6e56e62c2be41cf6e3c (diff)
downloadgcc-de1923f9f4d5344694c22ca883aeb15caf635734.zip
gcc-de1923f9f4d5344694c22ca883aeb15caf635734.tar.gz
gcc-de1923f9f4d5344694c22ca883aeb15caf635734.tar.bz2
tree-optimization/116463 - complex lowering leaves around dead stmts
Complex lowering generally replaces existing complex defs with COMPLEX_EXPRs but those might be dead when it can always refer to components from the lattice. This in turn can pessimize followup transforms like forwprop and reassoc, the following makes sure to get rid of dead COMPLEX_EXPRs generated by using simple_dce_from_worklist. PR tree-optimization/116463 * tree-complex.cc: Include tree-ssa-dce.h. (dce_worklist): New global. (update_complex_assignment): Add SSA def to the DCE worklist. (tree_lower_complex): Perform DCE.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-complex.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/tree-complex.cc b/gcc/tree-complex.cc
index dfb45b9..7480c07 100644
--- a/gcc/tree-complex.cc
+++ b/gcc/tree-complex.cc
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see
#include "case-cfn-macros.h"
#include "builtins.h"
#include "optabs-tree.h"
+#include "tree-ssa-dce.h"
/* For each complex ssa name, a lattice value. We're interested in finding
out whether a complex number is degenerate in some way, having only real
@@ -88,6 +89,9 @@ static vec<gphi *> phis_to_revisit;
/* BBs that need EH cleanup. */
static bitmap need_eh_cleanup;
+/* SSA defs we should try to DCE. */
+static bitmap dce_worklist;
+
/* Lookup UID in the complex_variable_components hashtable and return the
associated tree. */
static tree
@@ -731,6 +735,7 @@ update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i)
update_stmt (stmt);
if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt))
bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
+ bitmap_set_bit (dce_worklist, SSA_NAME_VERSION (gimple_assign_lhs (stmt)));
update_complex_components (gsi, gsi_stmt (*gsi), r, i);
}
@@ -1962,6 +1967,7 @@ tree_lower_complex (void)
complex_propagate.ssa_propagate ();
need_eh_cleanup = BITMAP_ALLOC (NULL);
+ dce_worklist = BITMAP_ALLOC (NULL);
complex_variable_components = new int_tree_htab_type (10);
@@ -2008,6 +2014,9 @@ tree_lower_complex (void)
gsi_commit_edge_inserts ();
+ simple_dce_from_worklist (dce_worklist, need_eh_cleanup);
+ BITMAP_FREE (dce_worklist);
+
unsigned todo
= gimple_purge_all_dead_eh_edges (need_eh_cleanup) ? TODO_cleanup_cfg : 0;
BITMAP_FREE (need_eh_cleanup);