From patchwork Fri Nov 12 17:54:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1554502 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=qy4p+71A; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 4HrR7K3qdFz9sCD for ; Sat, 13 Nov 2021 04:54:53 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 530F2385802D for ; Fri, 12 Nov 2021 17:54:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 530F2385802D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636739691; bh=j2DdmT6v0ulReqjwuyHY2qQz5sAxkn+/Y2BhGynY3Pc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qy4p+71ACT5qZgoZkt29taDY1jnbAEEBS0M9DnPXtSZTcHVi5VQzCkT/+Qw3gk54N tCHDyE6T4Ew+wb1AXH5lae7jklAHfhLxtOmWeIDhgqERjilQQOEIeEX8aO956i420a 5iCcBNJrJL2v/J1GZ5qr69WGAtdQhnX6l2frEQA0= 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 3EC15385840B for ; Fri, 12 Nov 2021 17:54:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3EC15385840B 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 F0D03D6E for ; Fri, 12 Nov 2021 09:54:30 -0800 (PST) Received: from localhost (unknown [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97F393F718 for ; Fri, 12 Nov 2021 09:54:30 -0800 (PST) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] vect: Fix vect_is_reduction Date: Fri, 12 Nov 2021 17:54:29 +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, KAM_SHORT, 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" The current definition of vect_is_reduction (provided for target costing) misses some pattern statements. Regstrapped on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard gcc/ * tree-vectorizer.h (vect_is_reduction): Use STMT_VINFO_REDUC_IDX. gcc/testsuite/ * gcc.target/aarch64/sve/cost_model_13.c: New test. --- .../gcc.target/aarch64/sve/cost_model_13.c | 16 ++++++++++++++++ gcc/tree-vectorizer.h | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/cost_model_13.c diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cost_model_13.c b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_13.c new file mode 100644 index 00000000000..95f2ce91f80 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_13.c @@ -0,0 +1,16 @@ +/* { dg-options "-O3 -mtune=neoverse-v1" } */ + +int +f11 (short *restrict x, int n) +{ + short res = 0; + for (int i = 0; i < n; ++i) + res += x[i]; + return res; +} + +/* We should use SVE rather than Advanced SIMD. */ +/* { dg-final { scan-assembler {\tld1h\tz[0-9]+\.h,} } } */ +/* { dg-final { scan-assembler {\tadd\tz[0-9]+\.h,} } } */ +/* { dg-final { scan-assembler-not {\tldr\tq[0-9]+,} } } */ +/* { dg-final { scan-assembler-not {\tv[0-9]+\.8h,} } } */ diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 0eb13d6cc74..76e81ea546a 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -2372,8 +2372,7 @@ vect_is_store_elt_extraction (vect_cost_for_stmt kind, stmt_vec_info stmt_info) inline bool vect_is_reduction (stmt_vec_info stmt_info) { - return (STMT_VINFO_REDUC_DEF (stmt_info) - || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))); + return STMT_VINFO_REDUC_IDX (stmt_info) >= 0; } /* If STMT_INFO describes a reduction, return the vect_reduction_type