From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 292183858D28 for ; Wed, 21 Jun 2023 11:41:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 292183858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5A4E021BF9; Wed, 21 Jun 2023 11:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687347699; 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=Ys35gZhFqSoU348Q7ulebBZpbgTJLhEUupa65UWawz8=; b=eDPSDjDq8GUVBEFfYt1HfHEIgDDCbvfZDjHK1AQNeNd5h0176URJw4/St03E6DYPKn5tUj qbkbxc05Zz7GYWofScshzCxm4vyQ5IHxr9UNhFGvxJoSoa6NuOHNWcH9MLvUFoFkAvdG8J ZsUYyuNK71e1Pa/Gr3ljoBa5V56/OZE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687347699; 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=Ys35gZhFqSoU348Q7ulebBZpbgTJLhEUupa65UWawz8=; b=19pE7t4713/1qlvpGHIUs5+mcXaDOXV4aywboGdvIy1d4OX6HqonFoZln6nULKr7iuv7rp 2fkaOD97W4pCrhAQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3793C2C142; Wed, 21 Jun 2023 11:41:39 +0000 (UTC) Date: Wed, 21 Jun 2023 11:41:39 +0000 (UTC) From: Richard Biener To: Ju-Zhe Zhong cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH]: [NFC] Move can_vec_mask_load_store_p and get_len_load_store_mode from "optabs-query" into "optabs-tree" In-Reply-To: <20230621113338.290127-1-juzhe.zhong@rivai.ai> Message-ID: References: <20230621113338.290127-1-juzhe.zhong@rivai.ai> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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,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 Wed, 21 Jun 2023, juzhe.zhong@rivai.ai wrote: > From: Ju-Zhe Zhong > > Since we want both can_vec_mask_load_store_p and get_len_load_store_mode > can see "internal_fn", move these 2 functions into optabs-tree. OK. Thanks, Richard. > gcc/ChangeLog: > > * optabs-query.cc (can_vec_mask_load_store_p): Move to optabs-tree.cc. > (get_len_load_store_mode): Ditto. > * optabs-query.h (can_vec_mask_load_store_p): Move to optabs-tree.h. > (get_len_load_store_mode): Ditto. > * optabs-tree.cc (can_vec_mask_load_store_p): New function. > (get_len_load_store_mode): Ditto. > * optabs-tree.h (can_vec_mask_load_store_p): Ditto. > (get_len_load_store_mode): Ditto. > * tree-if-conv.cc: include optabs-tree instead of optabs-query > > --- > gcc/optabs-query.cc | 66 --------------------------------------------- > gcc/optabs-query.h | 2 -- > gcc/optabs-tree.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++ > gcc/optabs-tree.h | 2 ++ > gcc/tree-if-conv.cc | 2 +- > 5 files changed, 68 insertions(+), 69 deletions(-) > > diff --git a/gcc/optabs-query.cc b/gcc/optabs-query.cc > index 276f8408dd7..2fdd0d34354 100644 > --- a/gcc/optabs-query.cc > +++ b/gcc/optabs-query.cc > @@ -558,72 +558,6 @@ can_mult_highpart_p (machine_mode mode, bool uns_p) > return 0; > } > > -/* Return true if target supports vector masked load/store for mode. */ > - > -bool > -can_vec_mask_load_store_p (machine_mode mode, > - machine_mode mask_mode, > - bool is_load) > -{ > - optab op = is_load ? maskload_optab : maskstore_optab; > - machine_mode vmode; > - > - /* If mode is vector mode, check it directly. */ > - if (VECTOR_MODE_P (mode)) > - return convert_optab_handler (op, mode, mask_mode) != CODE_FOR_nothing; > - > - /* Otherwise, return true if there is some vector mode with > - the mask load/store supported. */ > - > - /* See if there is any chance the mask load or store might be > - vectorized. If not, punt. */ > - scalar_mode smode; > - if (!is_a (mode, &smode)) > - return false; > - > - vmode = targetm.vectorize.preferred_simd_mode (smode); > - if (VECTOR_MODE_P (vmode) > - && targetm.vectorize.get_mask_mode (vmode).exists (&mask_mode) > - && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) > - return true; > - > - auto_vector_modes vector_modes; > - targetm.vectorize.autovectorize_vector_modes (&vector_modes, true); > - for (machine_mode base_mode : vector_modes) > - if (related_vector_mode (base_mode, smode).exists (&vmode) > - && targetm.vectorize.get_mask_mode (vmode).exists (&mask_mode) > - && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) > - return true; > - return false; > -} > - > -/* If target supports vector load/store with length for vector mode MODE, > - return the corresponding vector mode, otherwise return opt_machine_mode (). > - There are two flavors for vector load/store with length, one is to measure > - length with bytes, the other is to measure length with lanes. > - As len_{load,store} optabs point out, for the flavor with bytes, we use > - VnQI to wrap the other supportable same size vector modes. */ > - > -opt_machine_mode > -get_len_load_store_mode (machine_mode mode, bool is_load) > -{ > - optab op = is_load ? len_load_optab : len_store_optab; > - gcc_assert (VECTOR_MODE_P (mode)); > - > - /* Check if length in lanes supported for this mode directly. */ > - if (direct_optab_handler (op, mode)) > - return mode; > - > - /* Check if length in bytes supported for same vector size VnQI. */ > - machine_mode vmode; > - poly_uint64 nunits = GET_MODE_SIZE (mode); > - if (related_vector_mode (mode, QImode, nunits).exists (&vmode) > - && direct_optab_handler (op, vmode)) > - return vmode; > - > - return opt_machine_mode (); > -} > - > /* Return true if there is a compare_and_swap pattern. */ > > bool > diff --git a/gcc/optabs-query.h b/gcc/optabs-query.h > index b266d2fe990..043e9791bc1 100644 > --- a/gcc/optabs-query.h > +++ b/gcc/optabs-query.h > @@ -187,8 +187,6 @@ enum insn_code find_widening_optab_handler_and_mode (optab, machine_mode, > machine_mode, > machine_mode *); > int can_mult_highpart_p (machine_mode, bool); > -bool can_vec_mask_load_store_p (machine_mode, machine_mode, bool); > -opt_machine_mode get_len_load_store_mode (machine_mode, bool); > bool can_compare_and_swap_p (machine_mode, bool); > bool can_atomic_exchange_p (machine_mode, bool); > bool can_atomic_load_p (machine_mode); > diff --git a/gcc/optabs-tree.cc b/gcc/optabs-tree.cc > index 33ca529094d..77bf745ae40 100644 > --- a/gcc/optabs-tree.cc > +++ b/gcc/optabs-tree.cc > @@ -543,3 +543,68 @@ target_supports_op_p (tree type, enum tree_code code, > && optab_handler (ot, TYPE_MODE (type)) != CODE_FOR_nothing); > } > > +/* Return true if target supports vector masked load/store for mode. */ > + > +bool > +can_vec_mask_load_store_p (machine_mode mode, > + machine_mode mask_mode, > + bool is_load) > +{ > + optab op = is_load ? maskload_optab : maskstore_optab; > + machine_mode vmode; > + > + /* If mode is vector mode, check it directly. */ > + if (VECTOR_MODE_P (mode)) > + return convert_optab_handler (op, mode, mask_mode) != CODE_FOR_nothing; > + > + /* Otherwise, return true if there is some vector mode with > + the mask load/store supported. */ > + > + /* See if there is any chance the mask load or store might be > + vectorized. If not, punt. */ > + scalar_mode smode; > + if (!is_a (mode, &smode)) > + return false; > + > + vmode = targetm.vectorize.preferred_simd_mode (smode); > + if (VECTOR_MODE_P (vmode) > + && targetm.vectorize.get_mask_mode (vmode).exists (&mask_mode) > + && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) > + return true; > + > + auto_vector_modes vector_modes; > + targetm.vectorize.autovectorize_vector_modes (&vector_modes, true); > + for (machine_mode base_mode : vector_modes) > + if (related_vector_mode (base_mode, smode).exists (&vmode) > + && targetm.vectorize.get_mask_mode (vmode).exists (&mask_mode) > + && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) > + return true; > + return false; > +} > + > +/* If target supports vector load/store with length for vector mode MODE, > + return the corresponding vector mode, otherwise return opt_machine_mode (). > + There are two flavors for vector load/store with length, one is to measure > + length with bytes, the other is to measure length with lanes. > + As len_{load,store} optabs point out, for the flavor with bytes, we use > + VnQI to wrap the other supportable same size vector modes. */ > + > +opt_machine_mode > +get_len_load_store_mode (machine_mode mode, bool is_load) > +{ > + optab op = is_load ? len_load_optab : len_store_optab; > + gcc_assert (VECTOR_MODE_P (mode)); > + > + /* Check if length in lanes supported for this mode directly. */ > + if (direct_optab_handler (op, mode)) > + return mode; > + > + /* Check if length in bytes supported for same vector size VnQI. */ > + machine_mode vmode; > + poly_uint64 nunits = GET_MODE_SIZE (mode); > + if (related_vector_mode (mode, QImode, nunits).exists (&vmode) > + && direct_optab_handler (op, vmode)) > + return vmode; > + > + return opt_machine_mode (); > +} > diff --git a/gcc/optabs-tree.h b/gcc/optabs-tree.h > index 526bfe8761b..a3f79b6bd43 100644 > --- a/gcc/optabs-tree.h > +++ b/gcc/optabs-tree.h > @@ -47,5 +47,7 @@ bool expand_vec_cond_expr_p (tree, tree, enum tree_code); > void init_tree_optimization_optabs (tree); > bool target_supports_op_p (tree, enum tree_code, > enum optab_subtype = optab_default); > +bool can_vec_mask_load_store_p (machine_mode, machine_mode, bool); > +opt_machine_mode get_len_load_store_mode (machine_mode, bool); > > #endif > diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc > index 1393ce184e3..e342532a343 100644 > --- a/gcc/tree-if-conv.cc > +++ b/gcc/tree-if-conv.cc > @@ -92,7 +92,7 @@ along with GCC; see the file COPYING3. If not see > #include "ssa.h" > #include "expmed.h" > #include "expr.h" > -#include "optabs-query.h" > +#include "optabs-tree.h" > #include "gimple-pretty-print.h" > #include "alias.h" > #include "fold-const.h" > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)