Hi.
When expanding a VEC_COND_EXPR it happens that first argument (a SSA_NAME)
that can be no longer used. When that happens we need to remove the SSA_NAME,
otherwise we end up expanding it and for targets like s390x, there's no optab
expansion. We need to remove them at both places as -O0 does not help us
with a dead SSA_NAMEs after vector lowering.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Cross-compiler for s390x was tested as well for problematic test-case.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
PR tree-optimization/95745
PR middle-end/95830
* gimple-isel.cc (gimple_expand_vec_cond_exprs): Delete dead
SSA_NAMEs used as the first argument of a VEC_COND_EXPR. Always
return 0.
* tree-vect-generic.c (expand_vector_condition): Remove dead
SSA_NAMEs used as the firs argument of a VEC_COND_EXPR.
---
gcc/gimple-isel.cc | 11 +++++++++--
gcc/tree-vect-generic.c | 9 ++++++++-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index 97f92080503..25b893224af 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -178,7 +178,6 @@ gimple_expand_vec_cond_exprs (void)
{
gimple_stmt_iterator gsi;
basic_block bb;
- bool cfg_changed = false;
hash_map<tree, unsigned int> vec_cond_ssa_name_uses;
FOR_EACH_BB_FN (bb, cfun)
@@ -196,7 +195,15 @@ gimple_expand_vec_cond_exprs (void)
}
}
- return cfg_changed ? TODO_cleanup_cfg : 0;
+ for (hash_map<tree, unsigned int>::iterator it =
vec_cond_ssa_name_uses.begin ();
+ it != vec_cond_ssa_name_uses.end (); ++it)
+ if (num_imm_uses ((*it).first) == 0)
+ {
+ gsi = gsi_for_stmt (SSA_NAME_DEF_STMT ((*it).first));
+ gsi_remove (&gsi, true);
+ }
+
+ return 0;
}
namespace {
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 83d399a7898..2479368743d 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -954,10 +954,11 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
tree comp_index = index;
location_t loc = gimple_location (gsi_stmt (*gsi));
tree_code code = TREE_CODE (a);
+ gassign *assign = NULL;
if (code == SSA_NAME)
{
- gassign *assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a));
+ assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a));
if (assign != NULL
&& TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) ==
tcc_comparison)
{
@@ -1064,6 +1065,12 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
constr = build_constructor (type, v);
gimple_assign_set_rhs_from_tree (gsi, constr);
update_stmt (gsi_stmt (*gsi));
+
+ if (a_is_comparison && num_imm_uses (gimple_assign_lhs (assign)) == 0)
+ {
+ gimple_stmt_iterator gsi = gsi_for_stmt (assign);
+ gsi_remove (&gsi, true);
+ }
}
static tree
--
2.27.0