From patchwork Fri Nov 12 17:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1554490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=hEZNhoMN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HrQlz43kmz9sCD for ; Sat, 13 Nov 2021 04:38:07 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79B3C3858036 for ; Fri, 12 Nov 2021 17:38:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79B3C3858036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636738685; bh=qwzAh4AYoeecgV5QiGRu3l5uptBbSSYWzysqi25tjw0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hEZNhoMNkuVWJu9MSkq3+iOHvl7hTLLO6leWQFWZKr222/sdNZWnu3Gd/Dkg6F5SD Sl0BV0dZvNsbHcovlReHROA9GzxBxc5iDfWzcI/DSyMNsokGFltkjoYjXdkOq/tgi0 DqjnjgcNG/Svx75QFA23vHTfGFzia71D32mDKYFU= 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 0C0263858034 for ; Fri, 12 Nov 2021 17:37:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C0263858034 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 BC8EDD6E for ; Fri, 12 Nov 2021 09:37:17 -0800 (PST) Received: from localhost (unknown [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62F8B3F718 for ; Fri, 12 Nov 2021 09:37:17 -0800 (PST) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] aarch64: Remove vectype from latency tests Date: Fri, 12 Nov 2021 17:37:16 +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=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch gets the scalar mode of a reduction operation from the gimple stmt rather than the vectype. This makes it more suitable for use in scalar costs. Tested on aarch64-linux-gnu & applied. Richard gcc/ * config/aarch64/aarch64.c (aarch64_sve_in_loop_reduction_latency): Remove vectype parameter and get floatness from the type of the stmt lhs instead. (arch64_in_loop_reduction_latency): Likewise. (aarch64_detect_vector_stmt_subtype): Update caller. (aarch64_vector_costs::count_ops): Likewise. --- gcc/config/aarch64/aarch64.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index c8a3cb38473..416362beefd 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -15220,14 +15220,13 @@ aarch64_sve_only_stmt_p (stmt_vec_info stmt_info, tree vectype) return false; } -/* We are considering implementing STMT_INFO using SVE vector type VECTYPE. - If STMT_INFO is an in-loop reduction that SVE supports directly, return - its latency in cycles, otherwise return zero. SVE_COSTS specifies the - latencies of the relevant instructions. */ +/* We are considering implementing STMT_INFO using SVE. If STMT_INFO is an + in-loop reduction that SVE supports directly, return its latency in cycles, + otherwise return zero. SVE_COSTS specifies the latencies of the relevant + instructions. */ static unsigned int aarch64_sve_in_loop_reduction_latency (vec_info *vinfo, stmt_vec_info stmt_info, - tree vectype, const sve_vec_cost *sve_costs) { switch (vect_reduc_type (vinfo, stmt_info)) @@ -15236,7 +15235,7 @@ aarch64_sve_in_loop_reduction_latency (vec_info *vinfo, return sve_costs->clast_cost; case FOLD_LEFT_REDUCTION: - switch (GET_MODE_INNER (TYPE_MODE (vectype))) + switch (TYPE_MODE (TREE_TYPE (gimple_get_lhs (stmt_info->stmt)))) { case E_HFmode: case E_BFmode: @@ -15268,14 +15267,10 @@ aarch64_sve_in_loop_reduction_latency (vec_info *vinfo, Advanced SIMD implementation. - If VEC_FLAGS & VEC_ANY_SVE, return the loop carry latency of the - SVE implementation. - - VECTYPE is the type of vector that the vectorizer is considering using - for STMT_INFO, which might be different from the type of vector described - by VEC_FLAGS. */ + SVE implementation. */ static unsigned int aarch64_in_loop_reduction_latency (vec_info *vinfo, stmt_vec_info stmt_info, - tree vectype, unsigned int vec_flags) + unsigned int vec_flags) { const cpu_vector_cost *vec_costs = aarch64_tune_params.vec_costs; const sve_vec_cost *sve_costs = nullptr; @@ -15287,16 +15282,16 @@ aarch64_in_loop_reduction_latency (vec_info *vinfo, stmt_vec_info stmt_info, if (sve_costs) { unsigned int latency - = aarch64_sve_in_loop_reduction_latency (vinfo, stmt_info, vectype, - sve_costs); + = aarch64_sve_in_loop_reduction_latency (vinfo, stmt_info, sve_costs); if (latency) return latency; } /* Handle scalar costs. */ + bool is_float = FLOAT_TYPE_P (TREE_TYPE (gimple_get_lhs (stmt_info->stmt))); if (vec_flags == 0) { - if (FLOAT_TYPE_P (vectype)) + if (is_float) return vec_costs->scalar_fp_stmt_cost; return vec_costs->scalar_int_stmt_cost; } @@ -15305,7 +15300,7 @@ aarch64_in_loop_reduction_latency (vec_info *vinfo, stmt_vec_info stmt_info, with a vector reduction outside the loop. */ const simd_vec_cost *simd_costs = aarch64_simd_vec_costs_for_flags (vec_flags); - if (FLOAT_TYPE_P (vectype)) + if (is_float) return simd_costs->fp_stmt_cost; return simd_costs->int_stmt_cost; } @@ -15382,8 +15377,7 @@ aarch64_detect_vector_stmt_subtype (vec_info *vinfo, vect_cost_for_stmt kind, && sve_costs) { unsigned int latency - = aarch64_sve_in_loop_reduction_latency (vinfo, stmt_info, vectype, - sve_costs); + = aarch64_sve_in_loop_reduction_latency (vinfo, stmt_info, sve_costs); if (latency) return latency; } @@ -15570,8 +15564,7 @@ aarch64_vector_costs::count_ops (unsigned int count, vect_cost_for_stmt kind, && vect_is_reduction (stmt_info)) { unsigned int base - = aarch64_in_loop_reduction_latency (m_vinfo, stmt_info, vectype, - vec_flags); + = aarch64_in_loop_reduction_latency (m_vinfo, stmt_info, vec_flags); if (vect_reduc_type (m_vinfo, stmt_info) == FOLD_LEFT_REDUCTION) { if (aarch64_sve_mode_p (TYPE_MODE (vectype)))