https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94443
--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> --- On Thu, 2 Apr 2020, linkw at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94443 > > --- Comment #4 from Kewen Lin <linkw at gcc dot gnu.org> --- > This case has one conversion insn generated after bit_field_ref, the patch > introduces one stupid mistake to use gsi_insert_before instead of > gsi_insert_seq_before, it leads to miss the conversion insn. The below patch > makes it work. It also polishes copy related code a bit although not really > necessary to make this case pass. > > diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c > index c9b6534..4c2c9f7 100644 > --- a/gcc/tree-vect-loop.c > +++ b/gcc/tree-vect-loop.c > @@ -8050,7 +8050,7 @@ vectorizable_live_operation (stmt_vec_info stmt_info, > if (stmts) > { > gimple_stmt_iterator exit_gsi = gsi_after_labels (exit_bb); > - gsi_insert_before (&exit_gsi, stmts, GSI_CONTINUE_LINKING); > + gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT); > > /* Remove existing phi from lhs and create one copy from new_tree. */ > tree lhs_phi = NULL_TREE; > @@ -8060,10 +8060,10 @@ vectorizable_live_operation (stmt_vec_info stmt_info, > gimple *phi = gsi_stmt (gsi); > if ((gimple_phi_arg_def (phi, 0) == lhs)) > { > - remove_phi_node (&gsi, false); > lhs_phi = gimple_phi_result (phi); > gimple *copy = gimple_build_assign (lhs_phi, new_tree); > - gsi_insert_after (&exit_gsi, copy, GSI_CONTINUE_LINKING); > + gsi_insert_after (&exit_gsi, copy, GSI_NEW_STMT); this should also use gsi_insert_before, otherwise if the first stmt after labels has a use of lhs_phi then SSA will be corrupt. > + remove_phi_node (&gsi, false); I prefer to have the PHI removed before you re-use its LHS. OK with those changes. > break; > } > } > >