From a8f0278ade1353e3e6389aa7a00525b6e9b723ab Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 20 Dec 2023 13:18:51 +0100 Subject: Improve DCE of dead parts of a permute chain gcc.dg/vect/bb-slp-pr78205.c is reported to have regressed with the PR113073 change and in the end it's due to the DCE performed by vect_transform_slp_perm_load_1 being imperfect. The following enhances it to also cover the CTOR and VIEW_CONVERT operations that might be involved. * tree-vect-slp.cc (vect_transform_slp_perm_load_1): Also handle CTOR and VIEW_CONVERT up to the load when performing chain DCE. --- gcc/tree-vect-slp.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'gcc') diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index a82fca4..1a357cb 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -8634,10 +8634,21 @@ vect_transform_slp_perm_load_1 (vec_info *vinfo, slp_tree node, for (unsigned i = 0; i < dr_chain.length (); ++i) if (!bitmap_bit_p (used_defs, i)) { - gimple *stmt = SSA_NAME_DEF_STMT (dr_chain[i]); - gimple_stmt_iterator rgsi = gsi_for_stmt (stmt); - gsi_remove (&rgsi, true); - release_defs (stmt); + tree def = dr_chain[i]; + do + { + gimple *stmt = SSA_NAME_DEF_STMT (def); + if (is_gimple_assign (stmt) + && (gimple_assign_rhs_code (stmt) == VIEW_CONVERT_EXPR + || gimple_assign_rhs_code (stmt) == CONSTRUCTOR)) + def = single_ssa_tree_operand (stmt, SSA_OP_USE); + else + def = NULL; + gimple_stmt_iterator rgsi = gsi_for_stmt (stmt); + gsi_remove (&rgsi, true); + release_defs (stmt); + } + while (def); } return true; -- cgit v1.1