On Fri, 1 Dec 2023, Richard Sandiford wrote: > Richard Biener <rguent...@suse.de> writes: > > When querying a single set of vector defs with the overloaded > > vect_get_vec_defs API then when you try to use the overload with > > the vector type specified the call will be ambiguous with the > > variant without the vector type. The following fixes this by > > re-ordering the vector type argument to come before the output > > def vector argument. > > > > I've changed vectorizable_conversion as that triggered this > > so it has coverage showing this works. The motivation is to > > reduce the number of (redundant) get_vectype_for_scalar_type > > calls. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > OK for trunk or shall I defer to stage1? > > LGTM. Think it's probably worth having now, in case we need it for > other fixes.
That's what I thought as well, pushed now. Thanks, Richard. > Thanks, > Richard > > > > > Thanks, > > Richard. > > > > * tree-vectorizer.h (vect_get_vec_defs): Re-order arguments. > > * tree-vect-stmts.cc (vect_get_vec_defs): Likewise. > > (vectorizable_condition): Update caller. > > (vectorizable_comparison_1): Likewise. > > (vectorizable_conversion): Specify the vector type to be > > used for invariant/external defs. > > * tree-vect-loop.cc (vect_transform_reduction): Update caller. > > --- > > gcc/tree-vect-loop.cc | 6 +++--- > > gcc/tree-vect-stmts.cc | 42 +++++++++++++++++++++--------------------- > > gcc/tree-vectorizer.h | 8 ++++---- > > 3 files changed, 28 insertions(+), 28 deletions(-) > > > > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > > index 3df020d2228..dd584ab4a42 100644 > > --- a/gcc/tree-vect-loop.cc > > +++ b/gcc/tree-vect-loop.cc > > @@ -8504,11 +8504,11 @@ vect_transform_reduction (loop_vec_info loop_vinfo, > > gcc_assert (single_defuse_cycle > > && (reduc_index == 1 || reduc_index == 2)); > > vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, > > - op.ops[0], &vec_oprnds0, truth_type_for (vectype_in), > > + op.ops[0], truth_type_for (vectype_in), &vec_oprnds0, > > reduc_index == 1 ? NULL_TREE : op.ops[1], > > - &vec_oprnds1, NULL_TREE, > > + NULL_TREE, &vec_oprnds1, > > reduc_index == 2 ? NULL_TREE : op.ops[2], > > - &vec_oprnds2, NULL_TREE); > > + NULL_TREE, &vec_oprnds2); > > } > > > > /* For single def-use cycles get one copy of the vectorized reduction > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > > index bf8c99779ae..067abac3917 100644 > > --- a/gcc/tree-vect-stmts.cc > > +++ b/gcc/tree-vect-stmts.cc > > @@ -1267,10 +1267,10 @@ vect_get_vec_defs_for_operand (vec_info *vinfo, > > stmt_vec_info stmt_vinfo, > > void > > vect_get_vec_defs (vec_info *vinfo, stmt_vec_info stmt_info, slp_tree > > slp_node, > > unsigned ncopies, > > - tree op0, vec<tree> *vec_oprnds0, tree vectype0, > > - tree op1, vec<tree> *vec_oprnds1, tree vectype1, > > - tree op2, vec<tree> *vec_oprnds2, tree vectype2, > > - tree op3, vec<tree> *vec_oprnds3, tree vectype3) > > + tree op0, tree vectype0, vec<tree> *vec_oprnds0, > > + tree op1, tree vectype1, vec<tree> *vec_oprnds1, > > + tree op2, tree vectype2, vec<tree> *vec_oprnds2, > > + tree op3, tree vectype3, vec<tree> *vec_oprnds3) > > { > > if (slp_node) > > { > > @@ -1309,10 +1309,10 @@ vect_get_vec_defs (vec_info *vinfo, stmt_vec_info > > stmt_info, slp_tree slp_node, > > tree op3, vec<tree> *vec_oprnds3) > > { > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > > - op0, vec_oprnds0, NULL_TREE, > > - op1, vec_oprnds1, NULL_TREE, > > - op2, vec_oprnds2, NULL_TREE, > > - op3, vec_oprnds3, NULL_TREE); > > + op0, NULL_TREE, vec_oprnds0, > > + op1, NULL_TREE, vec_oprnds1, > > + op2, NULL_TREE, vec_oprnds2, > > + op3, NULL_TREE, vec_oprnds3); > > } > > > > /* Helper function called by vect_finish_replace_stmt and > > @@ -5657,7 +5657,7 @@ vectorizable_conversion (vec_info *vinfo, > > { > > case NONE: > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > > - op0, &vec_oprnds0); > > + op0, vectype_in, &vec_oprnds0); > > /* vec_dest is intermediate type operand when multi_step_cvt. */ > > if (multi_step_cvt) > > { > > @@ -5696,9 +5696,9 @@ vectorizable_conversion (vec_info *vinfo, > > generate more than one vector stmt - i.e - we need to "unroll" > > the vector stmt by a factor VF/nunits. */ > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies * ninputs, > > - op0, &vec_oprnds0, > > + op0, vectype_in, &vec_oprnds0, > > code == WIDEN_LSHIFT_EXPR ? NULL_TREE : op1, > > - &vec_oprnds1); > > + vectype_in, &vec_oprnds1); > > if (code == WIDEN_LSHIFT_EXPR) > > { > > int oprnds_size = vec_oprnds0.length (); > > @@ -5753,7 +5753,7 @@ vectorizable_conversion (vec_info *vinfo, > > generate more than one vector stmt - i.e - we need to "unroll" > > the vector stmt by a factor VF/nunits. */ > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies * ninputs, > > - op0, &vec_oprnds0); > > + op0, vectype_in, &vec_oprnds0); > > /* Arguments are ready. Create the new vector stmts. */ > > if (cvt_type && modifier == NARROW_DST) > > FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0) > > @@ -12248,17 +12248,17 @@ vectorizable_condition (vec_info *vinfo, > > /* Handle cond expr. */ > > if (masked) > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > > - cond_expr, &vec_oprnds0, comp_vectype, > > - then_clause, &vec_oprnds2, vectype, > > + cond_expr, comp_vectype, &vec_oprnds0, > > + then_clause, vectype, &vec_oprnds2, > > reduction_type != EXTRACT_LAST_REDUCTION > > - ? else_clause : NULL, &vec_oprnds3, vectype); > > + ? else_clause : NULL, vectype, &vec_oprnds3); > > else > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > > - cond_expr0, &vec_oprnds0, comp_vectype, > > - cond_expr1, &vec_oprnds1, comp_vectype, > > - then_clause, &vec_oprnds2, vectype, > > + cond_expr0, comp_vectype, &vec_oprnds0, > > + cond_expr1, comp_vectype, &vec_oprnds1, > > + then_clause, vectype, &vec_oprnds2, > > reduction_type != EXTRACT_LAST_REDUCTION > > - ? else_clause : NULL, &vec_oprnds3, vectype); > > + ? else_clause : NULL, vectype, &vec_oprnds3); > > > > /* Arguments are ready. Create the new vector stmt. */ > > FOR_EACH_VEC_ELT (vec_oprnds0, i, vec_cond_lhs) > > @@ -12621,8 +12621,8 @@ vectorizable_comparison_1 (vec_info *vinfo, tree > > vectype, > > mask = vect_create_destination_var (lhs, mask_type); > > > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > > - rhs1, &vec_oprnds0, vectype, > > - rhs2, &vec_oprnds1, vectype); > > + rhs1, vectype, &vec_oprnds0, > > + rhs2, vectype, &vec_oprnds1); > > if (swap_p) > > std::swap (vec_oprnds0, vec_oprnds1); > > > > diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h > > index e4d7ab4567c..1810833a324 100644 > > --- a/gcc/tree-vectorizer.h > > +++ b/gcc/tree-vectorizer.h > > @@ -2263,10 +2263,10 @@ void vect_get_vec_defs (vec_info *, stmt_vec_info, > > slp_tree, unsigned, > > tree = NULL, vec<tree> * = NULL, > > tree = NULL, vec<tree> * = NULL); > > void vect_get_vec_defs (vec_info *, stmt_vec_info, slp_tree, unsigned, > > - tree, vec<tree> *, tree, > > - tree = NULL, vec<tree> * = NULL, tree = NULL, > > - tree = NULL, vec<tree> * = NULL, tree = NULL, > > - tree = NULL, vec<tree> * = NULL, tree = NULL); > > + tree, tree, vec<tree> *, > > + tree = NULL, tree = NULL, vec<tree> * = NULL, > > + tree = NULL, tree = NULL, vec<tree> * = NULL, > > + tree = NULL, tree = NULL, vec<tree> * = NULL); > > extern tree vect_init_vector (vec_info *, stmt_vec_info, tree, tree, > > gimple_stmt_iterator *); > > extern tree vect_get_slp_vect_def (slp_tree, unsigned); > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)