From patchwork Thu Dec 20 16:32:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1016841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-492903-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="c1waUjkW"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43LHPG0wVkz9s3q for ; Fri, 21 Dec 2018 03:33:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=wjrYnxnhGMk2kBpw3ZDe8ED+pOK3Fsm0uV+hd4BWrSUInH1LQr9vI Kv072UEcRiKYk/RLdQvz1+iiPgqi1zKw5GNFvEIZQDV6r2XywWmx0yg9yUYkpTqd 8sXigYUGztvY8O/IydRI/DBV8u10Ar7uyQcej1hnWdBHGZpZ849ugk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=MbREtqALGG5LRqkcZajr1aA8N1k=; b=c1waUjkWbvj18XAeTz5/ z589fvTKr4y5zA+8FiWR6ufhzK1Ir7oPRoTmNJQPGVdfJWE4+nZ31DfLhr1V21q0 Upi7LUbqDG7f3dih6DZ6frEUbIIGpY75mVeR+bquFoZrdE/kLkBjNnP5VBVM4ndC PJSGYV+Iurq0BFQMHS8yQC4= Received: (qmail 108930 invoked by alias); 20 Dec 2018 16:32:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 108918 invoked by uid 89); 20 Dec 2018 16:32:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.2 spammy=U*richard.sandiford X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Dec 2018 16:32:55 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AABD880D for ; Thu, 20 Dec 2018 08:32:53 -0800 (PST) Received: from localhost (unknown [10.32.99.101]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2F0C53F5C0 for ; Thu, 20 Dec 2018 08:32:53 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [AArch64][SVE] Fix IFN_COND_FMLA movprfx alternative Date: Thu, 20 Dec 2018 16:32:51 +0000 Message-ID: <87pntwrwek.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This patch fixes a cut-&-pasto in the (match_dup 4) version of "cond_". (It's a shame that there's so much cut-&-paste in these patterns, but it's hard to avoid without more infrastructure.) Applied after testing on aarch64-linux-gnu and aarch64_be-elf. Richard 2018-12-20 Richard Sandiford gcc/ * config/aarch64/aarch64-sve.md (*cond__4): Use sve_fmla_op rather than sve_fmad_op for the movprfx alternative. gcc/testsuite/ * gcc.target/aarch64/sve/fmla_2.c: New test. * gcc.target/aarch64/sve/fmla_2_run.c: Likewise Index: gcc/config/aarch64/aarch64-sve.md =================================================================== --- gcc/config/aarch64/aarch64-sve.md 2018-12-07 15:03:10.893433419 +0000 +++ gcc/config/aarch64/aarch64-sve.md 2018-12-20 16:31:20.946744405 +0000 @@ -3021,7 +3021,7 @@ (define_insn "*cond__4" "TARGET_SVE" "@ \t%0., %1/m, %2., %3. - movprfx\t%0, %4\;\t%0., %1/m, %2., %3." + movprfx\t%0, %4\;\t%0., %1/m, %2., %3." [(set_attr "movprfx" "*,yes")] ) Index: gcc/testsuite/gcc.target/aarch64/sve/fmla_2.c =================================================================== --- /dev/null 2018-11-29 13:15:04.463550658 +0000 +++ gcc/testsuite/gcc.target/aarch64/sve/fmla_2.c 2018-12-20 16:31:20.946744405 +0000 @@ -0,0 +1,19 @@ +/* { dg-options "-O3" } */ + +#include + +#define N 55 + +void __attribute__ ((noipa)) +f (double *restrict a, double *restrict b, double *restrict c, + double *restrict d, double *restrict e, int64_t *restrict cond) +{ + for (int i = 0; i < N; ++i) + { + a[i] = cond[i] ? __builtin_fma (c[i], d[i], e[i]) : e[i]; + b[i] = cond[i] ? __builtin_fma (c[i], e[i], d[i]) : d[i]; + } +} + +/* { dg-final { scan-assembler-times {\tfmla\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, z[0-9]+\.d\n} 2 } } */ +/* { dg-final { scan-assembler-not {\tfmad\t} } } */ Index: gcc/testsuite/gcc.target/aarch64/sve/fmla_2_run.c =================================================================== --- /dev/null 2018-11-29 13:15:04.463550658 +0000 +++ gcc/testsuite/gcc.target/aarch64/sve/fmla_2_run.c 2018-12-20 16:31:20.946744405 +0000 @@ -0,0 +1,28 @@ +/* { dg-do run { target aarch64_sve_hw } } */ +/* { dg-options "-O3" } */ + +#include "fmla_2.c" + +int __attribute__ ((optimize (1))) +main (void) +{ + double a[N], b[N], c[N], d[N], e[N]; + int64_t cond[N]; + + for (int i = 0; i < N; ++i) + { + c[i] = i + i % 5; + d[i] = i + i % 7; + e[i] = i + i % 9; + cond[i] = i % 3; + } + + f (a, b, c, d, e, cond); + + for (int i = 0; i < N; ++i) + if (a[i] != (cond[i] ? __builtin_fma (c[i], d[i], e[i]) : e[i]) + || b[i] != (cond[i] ? __builtin_fma (c[i], e[i], d[i]) : d[i])) + __builtin_abort (); + + return 0; +}