From patchwork Wed Dec 13 12:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 82052 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 DF750383A612 for ; Wed, 13 Dec 2023 12:32:52 +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 [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 9C8AE3861012 for ; Wed, 13 Dec 2023 12:32:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C8AE3861012 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 9C8AE3861012 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702470755; cv=none; b=G8skjlFseK+uZzoYiQaGvLdcW02b8aY8cjGUzqnY6IKQvLmt7wYADN7VDizOeINcINNV3Hmbusb7VpFDkbQZRQKtPBE74soVK8pdGByCqjySlEpGMTImxrv2Bx6myvqSny01x67inAjeNXQAlGGs8j69IDiQHku9a+Bk9jkyBW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702470755; c=relaxed/simple; bh=ulv++fLJGin07VrQ2HnZhKSn51GRkqEmBXu78m2F+xA=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=G2UwZFSyzhTiNgGLYgoimD5uxDMSMhd83DKJHAYMX6vlVSJoZvvsOXi2DRq2G6gMEsZJuKbBvJA98YRrKlN1kYQhxES3uSz+3K5o7wuF2JVRubuKL+O/3Etrctm2hjhtwdg/n85A6dqYKgj3eolBwNFyz0QVrFTh7fqG5OIpgWI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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 9E84B221C9 for ; Wed, 13 Dec 2023 12:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702470743; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=RxPFXp5HVv6XD1I3U89s9QK/tPG74VE2yelGOv63peA=; b=rJHFR/jPSnh2SGW/Kin8Fy1gO1lLOmVsxpI4XaVAKz9wIqtXKtTsSADb46AtnxkoJXAmef 5DCBzwIZ7BfJ6fakorMhlo927UTQCGLtNyApyjvFoaxcJP3u0VOEq0qf79wUalHYP/KODi HRPvwY7jkSTDitOVq7bZsa+DE/4LcKE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702470743; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=RxPFXp5HVv6XD1I3U89s9QK/tPG74VE2yelGOv63peA=; b=/vcB+iyJIfNoDzZAeDPEBzZAq0BOWEqmPYZx8Bci2KQWnCq2WKQTdKiyclAqtmQ7eFbXaT 9+fDXhDtQRWIvyCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702470743; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=RxPFXp5HVv6XD1I3U89s9QK/tPG74VE2yelGOv63peA=; b=rJHFR/jPSnh2SGW/Kin8Fy1gO1lLOmVsxpI4XaVAKz9wIqtXKtTsSADb46AtnxkoJXAmef 5DCBzwIZ7BfJ6fakorMhlo927UTQCGLtNyApyjvFoaxcJP3u0VOEq0qf79wUalHYP/KODi HRPvwY7jkSTDitOVq7bZsa+DE/4LcKE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702470743; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=RxPFXp5HVv6XD1I3U89s9QK/tPG74VE2yelGOv63peA=; b=/vcB+iyJIfNoDzZAeDPEBzZAq0BOWEqmPYZx8Bci2KQWnCq2WKQTdKiyclAqtmQ7eFbXaT 9+fDXhDtQRWIvyCA== Date: Wed, 13 Dec 2023 13:31:20 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 5/6] Allow poly_uint64 for group_size args to vector type query routines MIME-Version: 1.0 X-Spam-Level: ** X-Spam-Score: 2.32 X-Spam-Level: X-Spam-Score: -0.60 X-Spamd-Result: default: False [-0.60 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Flag: NO Authentication-Results: smtp-out1.suse.de; none X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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 Message-Id: <20231213123252.DF750383A612@sourceware.org> The following changes the unsigned group_size argument to a poly_uint64 one to avoid too much special-casing in callers for VLA vectors when passing down the effective maximum desirable vector size to vector type query routines. The intent is to be able to pass down the vectorization factor (times the SLP group size) eventually. * tree-vectorizer.h (get_vectype_for_scalar_type, get_mask_type_for_scalar_type, vect_get_vector_types_for_stmt): Change group_size argument to poly_uint64 type. (vect_get_mask_type_for_stmt): Remove prototype for no longer existing function. * tree-vect-stmts.cc (get_vectype_for_scalar_type): Change group_size argument to poly_uint64. (get_mask_type_for_scalar_type): Likewise. (vect_get_vector_types_for_stmt): Likewise. --- gcc/tree-vect-stmts.cc | 25 ++++++++++++++----------- gcc/tree-vectorizer.h | 7 +++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 88401a2a00b..a5e26b746fb 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -13297,14 +13297,14 @@ get_related_vectype_for_scalar_type (machine_mode prevailing_mode, tree get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type, - unsigned int group_size) + poly_uint64 group_size) { /* For BB vectorization, we should always have a group size once we've constructed the SLP tree; the only valid uses of zero GROUP_SIZEs are tentative requests during things like early data reference analysis and pattern recognition. */ if (is_a (vinfo)) - gcc_assert (vinfo->slp_instances.is_empty () || group_size != 0); + gcc_assert (vinfo->slp_instances.is_empty () || known_ne (group_size, 0)); else group_size = 0; @@ -13320,9 +13320,11 @@ get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type, /* If the natural choice of vector type doesn't satisfy GROUP_SIZE, try again with an explicit number of elements. */ + uint64_t cst_group_size; if (vectype - && group_size - && maybe_ge (TYPE_VECTOR_SUBPARTS (vectype), group_size)) + && group_size.is_constant (&cst_group_size) + && cst_group_size != 0 + && maybe_ge (TYPE_VECTOR_SUBPARTS (vectype), cst_group_size)) { /* Start with the biggest number of units that fits within GROUP_SIZE and halve it until we find a valid vector type. @@ -13336,7 +13338,7 @@ get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type, even though the group is not a multiple of that vector size. The BB vectorizer will then try to carve up the group into smaller pieces. */ - unsigned int nunits = 1 << floor_log2 (group_size); + unsigned int nunits = 1 << floor_log2 (cst_group_size); do { vectype = get_related_vectype_for_scalar_type (vinfo->vector_mode, @@ -13372,7 +13374,7 @@ get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type, slp_tree node) tree get_mask_type_for_scalar_type (vec_info *vinfo, tree scalar_type, - unsigned int group_size) + poly_uint64 group_size) { tree vectype = get_vectype_for_scalar_type (vinfo, scalar_type, group_size); @@ -14243,7 +14245,7 @@ opt_result vect_get_vector_types_for_stmt (vec_info *vinfo, stmt_vec_info stmt_info, tree *stmt_vectype_out, tree *nunits_vectype_out, - unsigned int group_size) + poly_uint64 group_size) { gimple *stmt = stmt_info->stmt; @@ -14252,7 +14254,7 @@ vect_get_vector_types_for_stmt (vec_info *vinfo, stmt_vec_info stmt_info, are tentative requests during things like early data reference analysis and pattern recognition. */ if (is_a (vinfo)) - gcc_assert (vinfo->slp_instances.is_empty () || group_size != 0); + gcc_assert (vinfo->slp_instances.is_empty () || known_ne (group_size, 0)); else group_size = 0; @@ -14281,7 +14283,7 @@ vect_get_vector_types_for_stmt (vec_info *vinfo, stmt_vec_info stmt_info, tree vectype; tree scalar_type = NULL_TREE; - if (group_size == 0 && STMT_VINFO_VECTYPE (stmt_info)) + if (known_eq (group_size, 0U) && STMT_VINFO_VECTYPE (stmt_info)) { vectype = STMT_VINFO_VECTYPE (stmt_info); if (dump_enabled_p ()) @@ -14310,10 +14312,11 @@ vect_get_vector_types_for_stmt (vec_info *vinfo, stmt_vec_info stmt_info, if (dump_enabled_p ()) { - if (group_size) + if (known_ne (group_size, 0U)) dump_printf_loc (MSG_NOTE, vect_location, "get vectype for scalar type (group size %d):" - " %T\n", group_size, scalar_type); + " %T\n", (int)constant_lower_bound (group_size), + scalar_type); else dump_printf_loc (MSG_NOTE, vect_location, "get vectype for scalar type: %T\n", scalar_type); diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index a2bab8676af..95240504d18 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -2204,9 +2204,9 @@ extern edge vec_init_loop_exit_info (class loop *); /* In tree-vect-stmts.cc. */ extern tree get_related_vectype_for_scalar_type (machine_mode, tree, poly_uint64 = 0); -extern tree get_vectype_for_scalar_type (vec_info *, tree, unsigned int = 0); +extern tree get_vectype_for_scalar_type (vec_info *, tree, poly_uint64 = 0); extern tree get_vectype_for_scalar_type (vec_info *, tree, slp_tree); -extern tree get_mask_type_for_scalar_type (vec_info *, tree, unsigned int = 0); +extern tree get_mask_type_for_scalar_type (vec_info *, tree, poly_uint64 = 0); extern tree get_mask_type_for_scalar_type (vec_info *, tree, slp_tree); extern tree get_same_sized_vectype (tree, tree); extern bool vect_chooses_same_modes_p (vec_info *, machine_mode); @@ -2295,8 +2295,7 @@ extern tree vect_gen_while (gimple_seq *, tree, tree, tree, extern tree vect_gen_while_not (gimple_seq *, tree, tree, tree); extern opt_result vect_get_vector_types_for_stmt (vec_info *, stmt_vec_info, tree *, - tree *, unsigned int = 0); -extern opt_tree vect_get_mask_type_for_stmt (stmt_vec_info, unsigned int = 0); + tree *, poly_uint64 = 0); /* In tree-vect-data-refs.cc. */ extern bool vect_can_force_dr_alignment_p (const_tree, poly_uint64);