Re: [29/46] Use stmt_vec_info instead of gimple stmts internally (part 2)
On Tue, Jul 24, 2018 at 12:04 PM Richard Sandiford wrote: > > This second part handles the less mechnical cases, i.e. those that don't > just involve swapping a gimple stmt for an existing stmt_vec_info. OK. > > 2018-07-24 Richard Sandiford > > gcc/ > * tree-vect-loop.c (vect_analyze_loop_operations): Look up the > statement before passing it to vect_analyze_stmt. > (vect_create_epilog_for_reduction): Use a stmt_vec_info to walk > the chain of phi vector definitions. Track the exit phi via its > stmt_vec_info. > (vectorizable_reduction): Set cond_stmt_vinfo directly from the > STMT_VINFO_REDUC_DEF. > * tree-vect-slp.c (vect_get_place_in_interleaving_chain): Use > stmt_vec_infos to handle the statement chains. > (vect_get_slp_defs): Record the first statement in the node > using a stmt_vec_info. > * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Look up > statements here and pass their stmt_vec_info down to subroutines. > (vect_init_vector_1): Hoist call to vinfo_for_stmt and pass it > down to vect_finish_stmt_generation. > (vect_init_vector, vect_get_vec_defs, vect_finish_replace_stmt) > (vect_finish_stmt_generation): Call vinfo_for_stmt and pass > stmt_vec_infos to subroutines. > (vect_remove_stores): Use stmt_vec_infos to handle the statement > chains. > > Index: gcc/tree-vect-loop.c > === > --- gcc/tree-vect-loop.c2018-07-24 10:23:35.376732054 +0100 > +++ gcc/tree-vect-loop.c2018-07-24 10:23:38.964700191 +0100 > @@ -1629,8 +1629,9 @@ vect_analyze_loop_operations (loop_vec_i > { > gimple *stmt = gsi_stmt (si); > if (!gimple_clobber_p (stmt) > - && !vect_analyze_stmt (stmt, _to_vectorize, NULL, NULL, > -_vec)) > + && !vect_analyze_stmt (loop_vinfo->lookup_stmt (stmt), > +_to_vectorize, > +NULL, NULL, _vec)) > return false; > } > } /* bbs */ > @@ -4832,11 +4833,11 @@ vect_create_epilog_for_reduction (vectree first_vect = PHI_RESULT (new_phis[0]); >gassign *new_vec_stmt = NULL; >vec_dest = vect_create_destination_var (scalar_dest, vectype); > - gimple *next_phi = new_phis[0]; > + stmt_vec_info next_phi_info = loop_vinfo->lookup_stmt (new_phis[0]); >for (int k = 1; k < ncopies; ++k) > { > - next_phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (next_phi)); > - tree second_vect = PHI_RESULT (next_phi); > + next_phi_info = STMT_VINFO_RELATED_STMT (next_phi_info); > + tree second_vect = PHI_RESULT (next_phi_info->stmt); >tree tem = make_ssa_name (vec_dest, new_vec_stmt); >new_vec_stmt = gimple_build_assign (tem, code, > first_vect, second_vect); > @@ -5573,11 +5574,12 @@ vect_create_epilog_for_reduction (vecelse > ratio = 1; > > + stmt_vec_info epilog_stmt_info = NULL; >for (k = 0; k < group_size; k++) > { >if (k % ratio == 0) > { > - epilog_stmt = new_phis[k / ratio]; > + epilog_stmt_info = loop_vinfo->lookup_stmt (new_phis[k / ratio]); > reduction_phi_info = reduction_phis[k / ratio]; > if (double_reduc) > inner_phi = inner_phis[k / ratio]; > @@ -5623,8 +5625,7 @@ vect_create_epilog_for_reduction (vec if (double_reduc) > STMT_VINFO_VEC_STMT (exit_phi_vinfo) = inner_phi; > else > - STMT_VINFO_VEC_STMT (exit_phi_vinfo) > - = vinfo_for_stmt (epilog_stmt); > + STMT_VINFO_VEC_STMT (exit_phi_vinfo) = epilog_stmt_info; >if (!double_reduc >|| STMT_VINFO_DEF_TYPE (exit_phi_vinfo) >!= vect_double_reduction_def) > @@ -6070,7 +6071,7 @@ vectorizable_reduction (gimple *stmt, gi >optab optab; >tree new_temp = NULL_TREE; >enum vect_def_type dt, cond_reduc_dt = vect_unknown_def_type; > - gimple *cond_reduc_def_stmt = NULL; > + stmt_vec_info cond_stmt_vinfo = NULL; >enum tree_code cond_reduc_op_code = ERROR_MARK; >tree scalar_type; >bool is_simple_use; > @@ -6348,7 +6349,7 @@ vectorizable_reduction (gimple *stmt, gi > && is_nonwrapping_integer_induction (def_stmt_info, loop)) > { > cond_reduc_dt = dt; > - cond_reduc_def_stmt = def_stmt_info; > + cond_stmt_vinfo = def_stmt_info; > } > } > } > @@ -6454,7 +6455,6 @@ vectorizable_reduction (gimple *stmt, gi > } >else if (cond_reduc_dt == vect_induction_def) > { > - stmt_vec_info cond_stmt_vinfo = vinfo_for_stmt >
[29/46] Use stmt_vec_info instead of gimple stmts internally (part 2)
This second part handles the less mechnical cases, i.e. those that don't just involve swapping a gimple stmt for an existing stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (vect_analyze_loop_operations): Look up the statement before passing it to vect_analyze_stmt. (vect_create_epilog_for_reduction): Use a stmt_vec_info to walk the chain of phi vector definitions. Track the exit phi via its stmt_vec_info. (vectorizable_reduction): Set cond_stmt_vinfo directly from the STMT_VINFO_REDUC_DEF. * tree-vect-slp.c (vect_get_place_in_interleaving_chain): Use stmt_vec_infos to handle the statement chains. (vect_get_slp_defs): Record the first statement in the node using a stmt_vec_info. * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Look up statements here and pass their stmt_vec_info down to subroutines. (vect_init_vector_1): Hoist call to vinfo_for_stmt and pass it down to vect_finish_stmt_generation. (vect_init_vector, vect_get_vec_defs, vect_finish_replace_stmt) (vect_finish_stmt_generation): Call vinfo_for_stmt and pass stmt_vec_infos to subroutines. (vect_remove_stores): Use stmt_vec_infos to handle the statement chains. Index: gcc/tree-vect-loop.c === --- gcc/tree-vect-loop.c2018-07-24 10:23:35.376732054 +0100 +++ gcc/tree-vect-loop.c2018-07-24 10:23:38.964700191 +0100 @@ -1629,8 +1629,9 @@ vect_analyze_loop_operations (loop_vec_i { gimple *stmt = gsi_stmt (si); if (!gimple_clobber_p (stmt) - && !vect_analyze_stmt (stmt, _to_vectorize, NULL, NULL, -_vec)) + && !vect_analyze_stmt (loop_vinfo->lookup_stmt (stmt), +_to_vectorize, +NULL, NULL, _vec)) return false; } } /* bbs */ @@ -4832,11 +4833,11 @@ vect_create_epilog_for_reduction (veclookup_stmt (new_phis[0]); for (int k = 1; k < ncopies; ++k) { - next_phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (next_phi)); - tree second_vect = PHI_RESULT (next_phi); + next_phi_info = STMT_VINFO_RELATED_STMT (next_phi_info); + tree second_vect = PHI_RESULT (next_phi_info->stmt); tree tem = make_ssa_name (vec_dest, new_vec_stmt); new_vec_stmt = gimple_build_assign (tem, code, first_vect, second_vect); @@ -5573,11 +5574,12 @@ vect_create_epilog_for_reduction (veclookup_stmt (new_phis[k / ratio]); reduction_phi_info = reduction_phis[k / ratio]; if (double_reduc) inner_phi = inner_phis[k / ratio]; @@ -5623,8 +5625,7 @@ vect_create_epilog_for_reduction (vec ops, slp_tree slp_node, vec > *vec_oprnds) { - gimple *first_stmt; int number_of_vects = 0, i; unsigned int child_index = 0; HOST_WIDE_INT lhs_size_unit, rhs_size_unit; @@ -3586,7 +3587,7 @@ vect_get_slp_defs (vec ops, slp_tr tree oprnd; bool vectorized_defs; - first_stmt = SLP_TREE_SCALAR_STMTS (slp_node)[0]; + stmt_vec_info first_stmt_info = SLP_TREE_SCALAR_STMTS (slp_node)[0]; FOR_EACH_VEC_ELT (ops, i, oprnd) { /* For each operand we check if it has vectorized definitions in a child @@ -3637,8 +3638,8 @@ vect_get_slp_defs (vec ops, slp_tr vect_schedule_slp_instance (), fix it by replacing LHS with RHS, if necessary. See vect_get_smallest_scalar_type () for details. */ - vect_get_smallest_scalar_type (first_stmt, _size_unit, - _size_unit); + vect_get_smallest_scalar_type (first_stmt_info, _size_unit, +_size_unit); if (rhs_size_unit != lhs_size_unit) { number_of_vects *= rhs_size_unit; Index: gcc/tree-vect-stmts.c === --- gcc/tree-vect-stmts.c 2018-07-24 10:23:35.384731983 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:23:38.968700155 +0100 @@ -622,7 +622,6 @@ vect_mark_stmts_to_be_vectorized (loop_v unsigned int i; stmt_vec_info stmt_vinfo; basic_block bb; - gimple *phi; bool live_p; enum vect_relevant relevant; @@ -636,27 +635,27 @@ vect_mark_stmts_to_be_vectorized (loop_v bb = bbs[i]; for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next ()) { - phi = gsi_stmt (si); + stmt_vec_info phi_info = loop_vinfo->lookup_stmt (gsi_stmt (si)); if (dump_enabled_p ()) { dump_printf_loc (MSG_NOTE, vect_location, "init: phi relevant? "); - dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);