From patchwork Sun Nov 13 10:02:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 60518 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 744863887F7A for ; Sun, 13 Nov 2022 10:05:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 744863887F7A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668333914; bh=mf9etWSat6mzorzKo80DLxzwyBnLR2wRRxPE7MHG/gI=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Khr3u/3uX+fuQ1YlVhf6GXQJhd8ecipzATZHHK1YVRcNPNQ23ZoNqROzFd+1kUOST g1Raa+pBHGHBBPw2RQlrVYKJTrBhGNGNAdHev/mZXDEKrDbdK/Wsn48zY86TqorYpS FqvyXRTbogpV8kmeYMcrfo0O2MLjtbj/Y9Rhn570= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 67EF5389EC62 for ; Sun, 13 Nov 2022 10:02:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67EF5389EC62 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 8389623A for ; Sun, 13 Nov 2022 02:02:30 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E84833F73D for ; Sun, 13 Nov 2022 02:02:23 -0800 (PST) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH 11/16] aarch64: Generalise _m rules for SVE intrinsics References: Date: Sun, 13 Nov 2022 10:02:22 +0000 In-Reply-To: (Richard Sandiford's message of "Sun, 13 Nov 2022 09:59:23 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-41.6 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 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 8e26bd8a60f..5b47dff0b41 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); } } @@ -3238,6 +3238,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 cb3eb76dd77..450a8d958a8 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -2152,7 +2152,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)) @@ -2790,7 +2790,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 0d130b871d0..623b9e3a07b 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.h +++ b/gcc/config/aarch64/aarch64-sve-builtins.h @@ -636,6 +636,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; /* Define all functions associated with the given group. */ @@ -877,6 +880,16 @@ function_base::call_properties (const function_instance &instance) const return flags; } +/* 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; +} + } #endif