From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 177DB3858D20 for ; Fri, 15 Dec 2023 07:39:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 177DB3858D20 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 177DB3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702625987; cv=none; b=v43hKjGd2gOq9MLFKe8JcUKCz+3wEpP4ifbli6zaHZhUxa1z8YcxpYby6pPapztF4whOJEXE6Bgg94/i5V4y1YjDchVGuE9IheCO5zKPBiYYP2SbzMplL5m6UcecgeRppKeMn5ks4QM1wDIfdv0qeg0U5nXAfNvw9romdzQH/YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702625987; c=relaxed/simple; bh=zoxULeNyW4AJtnWFcHxfoPbNX8W13WbjtS5OmPqhVNs=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=U5rLS4UwN+iy3CR2twbgzdi9E7uJMmjPzb5M9NP2rGYVxREtHP5qCtog52AqWWNBoJtarzGXgOUW0OARhEUlF6zJ9SdIZWodXz7Vc2LAx4UpCGeVANapKw8EpP1sB0Y/A89b330cdzBYC+SYEskND++2cMsJIMfPAHesBrDmTVo= 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-out2.suse.de (Postfix) with ESMTPS id D09F91F81E; Fri, 15 Dec 2023 07:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702625985; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6OT9ItHqEr2xQrrHTG4rCZ6t709TDLVou/Gpl0+3Fcc=; b=2IQ8FZjLlUWmXLxwyOlA1x7ZqTgult+/xAeibZTAoa7EdnBhIYi5Km3ROtwLwFADWJMPkK b/8pxY4OMHqV4esIDHkzpM1jWNRtM74sw2hG6Khsvhxmayu2haL6wCy95aYBDcTv1sCgGM U1GO4eTbv2GaJ2MWOpONiwaEHR/ttJM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702625985; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6OT9ItHqEr2xQrrHTG4rCZ6t709TDLVou/Gpl0+3Fcc=; b=+0XsOBZjn/CBgG8SAix61KRDQ7gGBv4wcN3/ZHFuZM43P51suhvOtbHFLPyzIeqm7HAchV rA0KFbvdCBO+WICQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702625984; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6OT9ItHqEr2xQrrHTG4rCZ6t709TDLVou/Gpl0+3Fcc=; b=Wg4u65eiwIqvGpaEoZ8Z6v769Bmb6VBzWzu+h78bPySZEHYZ/ty1TXwYPMgWsEvmrh3agr dCLWPJQBEBbVLEavb2uWxWzGPbsNXisGkopKBKvQEtSGfQmwxFFG8GZf9TsgbunEGk/r+a SdMApWDjtrfvKMlb3rZ+RV0Voc4eNrY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702625984; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6OT9ItHqEr2xQrrHTG4rCZ6t709TDLVou/Gpl0+3Fcc=; b=+vL4A3NoLgD+KCbsa39V4f8hXA92+F2vYcAcG5YLKFvjUJMHMp05RUY7/1nDqCzUndc5hw 0rj6L7TOSCXJ6rBw== Date: Fri, 15 Dec 2023 08:38:39 +0100 (CET) From: Richard Biener To: Richard Sandiford cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 5/6] Allow poly_uint64 for group_size args to vector type query routines In-Reply-To: Message-ID: <9366n2os-600q-rs42-o027-9s38668363q9@fhfr.qr> References: <20231213123247.47A3838708F9@sourceware.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Level: X-Spam-Score: -3.10 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -2.55 X-Spamd-Result: default: False [-2.55 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.19)[-0.959]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(0.74)[0.212]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; 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 X-Spam-Status: No, score=-11.5 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 List-Id: On Thu, 14 Dec 2023, Richard Sandiford wrote: > Richard Biener writes: > > 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. > > LGTM FWIW, although... > > > --- > > 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. > > ...it feels like this makes sense for VLA too in some form, if we > plan to keep it longer-term. It's not a trivial adaption though, > so would definitely be a separate patch. I did wonder if it's even possible to have multiple VLA vector sizes but then you do have these x2 and x4 modes which are exactly that, VLA vectors with a multiple number of elements? So practically the goal is to find a vector mode suitable for a given vectorization factor rather than a "size". Richard. > Thanks, > Richard > > > @@ -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); > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)