From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 1CD923856DD4; Fri, 1 Dec 2023 11:55:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CD923856DD4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701431717; bh=d9XLF2RMv6P8P5hBUffV5+JYwCPRC8g1nUE6fEiB1LM=; h=From:To:Subject:Date:From; b=Q/TpQFR2dyFnmGXt8h7Js+5oIkOLcdMbIkGymIg0cbe9Wd+YC6wvduhK+da6+zm6G BhbJXV9wJJM1lTNxfoX6WKFKBmAwOHZmnbcq2JwBlh+1EQZvaQAF3ZePGXeX8Hg23T dwdApeHe0h/9naYBA6BDngiue339rsLke9DmsLXo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-6053] Fix ambiguity between vect_get_vec_defs with/without vectype X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 9e6885467476da963e941986b14ffb57fee6bf50 X-Git-Newrev: 8332b991e42dbffd1f2a7b7aa9a23f5aa242e602 Message-Id: <20231201115517.1CD923856DD4@sourceware.org> Date: Fri, 1 Dec 2023 11:55:17 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8332b991e42dbffd1f2a7b7aa9a23f5aa242e602 commit r14-6053-g8332b991e42dbffd1f2a7b7aa9a23f5aa242e602 Author: Richard Biener Date: Fri Dec 1 11:14:53 2023 +0100 Fix ambiguity between vect_get_vec_defs with/without vectype 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. * 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. Diff: --- 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 *vec_oprnds0, tree vectype0, - tree op1, vec *vec_oprnds1, tree vectype1, - tree op2, vec *vec_oprnds2, tree vectype2, - tree op3, vec *vec_oprnds3, tree vectype3) + tree op0, tree vectype0, vec *vec_oprnds0, + tree op1, tree vectype1, vec *vec_oprnds1, + tree op2, tree vectype2, vec *vec_oprnds2, + tree op3, tree vectype3, vec *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 *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 * = NULL, tree = NULL, vec * = NULL); void vect_get_vec_defs (vec_info *, stmt_vec_info, slp_tree, unsigned, - tree, vec *, tree, - tree = NULL, vec * = NULL, tree = NULL, - tree = NULL, vec * = NULL, tree = NULL, - tree = NULL, vec * = NULL, tree = NULL); + tree, tree, vec *, + tree = NULL, tree = NULL, vec * = NULL, + tree = NULL, tree = NULL, vec * = NULL, + tree = NULL, tree = NULL, vec * = 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);