From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 951D23861002 for ; Tue, 5 Dec 2023 10:13:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 951D23861002 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 951D23861002 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701771231; cv=none; b=CFxZukO0NH+8dB4VIWtClmxQU+maeFgJgdpUi0XKs2SUO7GKkTzdQOwVBqb8Ouw6wF2mvMMWOLuFGPtxMXNZ9FSyc8crOn+WlANWCKg76uedU3v7Ju6SXEUIP//vITzB5kFh5/Ynp7WwTSDWLG56fyxqKQFMP5iyF+KjTy5T76g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701771231; c=relaxed/simple; bh=vKuqfBh+EgtLebRva+K5zivycLgR0dDuBjS4Pbj8Q9w=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=hCQPlUVxSOzF6IlatUtw67HCT16hIaO519uW0xR5xwXykCytA1Qu28ONKNyf0UdsEl0PKoWb86BNa6Y1vzp3zWpMBWI1PevYSjZIGVjTkYa1vCcoI1JJWnXBPLBMHq1YQXp7qiUexQzQ2Imd6H+Fvg7xHhpoL9DeO87JZRz2vzA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 006AD1570; Tue, 5 Dec 2023 02:14:34 -0800 (PST) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E62293F5A1; Tue, 5 Dec 2023 02:13:46 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [pushed v2 20/25] aarch64: Generalise _m rules for SVE intrinsics Date: Tue, 5 Dec 2023 10:13:18 +0000 Message-Id: <20231205101323.1914247-21-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231205101323.1914247-1-richard.sandiford@arm.com> References: <20231205101323.1914247-1-richard.sandiford@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-22.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,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: In SVE there was a simple rule that unary merging (_m) intrinsics had a separate initial argument to specify the values of inactive lanes, whereas other merging functions took inactive lanes from the first operand to the operation. That rule began to break down in SVE2, and it continues to do so in SME. This patch therefore adds a virtual function to specify whether the separate initial argument is present or not. The old rule is still the default. gcc/ * config/aarch64/aarch64-sve-builtins.h (function_shape::has_merge_argument_p): New member function. * config/aarch64/aarch64-sve-builtins.cc: (function_resolver::check_gp_argument): Use it. (function_expander::get_fallback_value): Likewise. * config/aarch64/aarch64-sve-builtins-shapes.cc (apply_predication): Likewise. (unary_convert_narrowt_def::has_merge_argument_p): New function. --- gcc/config/aarch64/aarch64-sve-builtins-shapes.cc | 10 ++++++++-- gcc/config/aarch64/aarch64-sve-builtins.cc | 4 ++-- gcc/config/aarch64/aarch64-sve-builtins.h | 13 +++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc b/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc index 2c25b122f05..68708712001 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc @@ -66,8 +66,8 @@ apply_predication (const function_instance &instance, tree return_type, the same type as the result. For unary_convert_narrowt it also provides the "bottom" half of active elements, and is present for all types of predication. */ - if ((argument_types.length () == 2 && instance.pred == PRED_m) - || instance.shape == shapes::unary_convert_narrowt) + auto nargs = argument_types.length () - 1; + if (instance.shape->has_merge_argument_p (instance, nargs)) argument_types.quick_insert (0, return_type); } } @@ -3271,6 +3271,12 @@ SHAPE (unary_convert) predicate. */ struct unary_convert_narrowt_def : public overloaded_base<1> { + bool + has_merge_argument_p (const function_instance &, unsigned int) const override + { + return true; + } + void build (function_builder &b, const function_group_info &group) const override { diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index d5ac1dc76c5..7950977c14b 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -2287,7 +2287,7 @@ function_resolver::check_gp_argument (unsigned int nops, if (pred != PRED_none) { /* Unary merge operations should use resolve_unary instead. */ - gcc_assert (nops != 1 || pred != PRED_m); + gcc_assert (!shape->has_merge_argument_p (*this, nops)); nargs = nops + 1; if (!check_num_arguments (nargs) || !require_vector_type (i, VECTOR_TYPE_svbool_t)) @@ -2997,7 +2997,7 @@ function_expander::get_fallback_value (machine_mode mode, unsigned int nops, gcc_assert (pred == PRED_m || pred == PRED_x); if (merge_argno == DEFAULT_MERGE_ARGNO) - merge_argno = nops == 1 && pred == PRED_m ? 0 : 1; + merge_argno = shape->has_merge_argument_p (*this, nops) ? 0 : 1; if (merge_argno == 0) return args[argno++]; diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h index e770a4042fe..b0218bbad6e 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.h +++ b/gcc/config/aarch64/aarch64-sve-builtins.h @@ -712,6 +712,9 @@ public: class function_shape { public: + virtual bool has_merge_argument_p (const function_instance &, + unsigned int) const; + virtual bool explicit_type_suffix_p (unsigned int) const = 0; /* True if the group suffix is present in overloaded names. @@ -987,6 +990,16 @@ function_base::vectors_per_tuple (const function_instance &instance) const return instance.group_suffix ().vectors_per_tuple; } +/* Return true if INSTANCE (which has NARGS arguments) has an initial + vector argument whose only purpose is to specify the values of + inactive lanes. */ +inline bool +function_shape::has_merge_argument_p (const function_instance &instance, + unsigned int nargs) const +{ + return nargs == 1 && instance.pred == PRED_m; +} + /* Return the mode of the result of a call. */ inline machine_mode function_expander::result_mode () const -- 2.25.1