From patchwork Fri Dec 1 11:27:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 81107 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C45EA385B53E for ; Fri, 1 Dec 2023 11:27:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id DA66D385B53C for ; Fri, 1 Dec 2023 11:27:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA66D385B53C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DA66D385B53C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701430062; cv=none; b=Ui1OPKXk+5EtCtJao1JTVR+bNgNth2IMdDoQ0cE0l7lGlvYT6idTgRmKTHl8KxFpCR42oX5phiunGdmoHaQDBLXKdtVgeIjFUq2VGoYnZMAfy6s2H5LSN4ZMgMQeQCkNDv7I5Cv8kNZLWYanxV61idFwDoWdUENrezM5M4nFJyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701430062; c=relaxed/simple; bh=uhBpyXu00rYl2+sJ2mQxQnLC8AQVCdwjIUd8QUocLuc=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version: Message-Id; b=rgv30EFVYoe7llImqLCphtRofu/yYypk7FfoRHrgrTQN4/SbQdzYADB1CVrtJoVBrWzdjrGxc97f/vyyA33hsgukr8AXCykN+0nxdqJi1NDA+uCbw3Mu0VxuyiaHolq89ATcMPuQmWcOSH8KAx0UF0HYBtZhg2dScCQ2OpvXdUA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A045821C63; Fri, 1 Dec 2023 11:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701430059; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=D8ClmPrKB/zVk3kpUr+GL1kh+vu/RFok/IbIdvH0PIk=; b=0NwruxG6Gytw9m6QIpXyDu9y+kO0wiySmR21HqnmcMYSrxCIrUl+w89twg5pDy37snihgT LMD27FwjmOktVnBZtmmo22iWLaDmUveaa3lCvRKFkjQzhSzvsmemXT64S/3GVRV+/eR4/q sVO26IzmsxdkK199fIAlb+dexnBvrks= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701430059; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=D8ClmPrKB/zVk3kpUr+GL1kh+vu/RFok/IbIdvH0PIk=; b=Uh9lb0mKrX3IkMw9puopxFqVy6/gmfFKUL+WMpUZ+SP9PJ3XY+8Mc5BJR3GkIV4hHlqI5u Rzp5vT03t6fkuwAg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 7352F13928; Fri, 1 Dec 2023 11:27:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id gVmlGSvDaWU4CQAAn2gu4w (envelope-from ); Fri, 01 Dec 2023 11:27:39 +0000 Date: Fri, 1 Dec 2023 12:27:38 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: richard.sandiford@arm.com Subject: [PATCH] Fix ambiguity between vect_get_vec_defs with/without vectype MIME-Version: 1.0 Message-Id: <20231201112739.7352F13928@imap2.dmz-prg2.suse.org> Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -4.10 X-Spamd-Result: default: False [-4.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org 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? 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 *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);