From patchwork Fri Sep 14 17:05:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Bolton X-Patchwork-Id: 183977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E1ED82C00A7 for ; Sat, 15 Sep 2012 03:06:01 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1348247163; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Content-class:MIME-Version:Content-Type:Subject:Date:Message-ID: From:To:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=6DEUeAY juwdoDTZS+iMyL5eWUfw=; b=D149NiDcDd3gQbgAsnMmBGGLBwv3N8zX23n+9A2 vuDouFl/NyC3I9Tgp4dawbMQJXgYCol1gsDDek3EQ2+BYDaAWBX1uZzZT9bZFPJc Hju/zCqbqiK7g1CWlCHw62qTTsBYnhPKT4JoczjW3fp36mkiTdb74nxgygf0E3KE zJz8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Content-class:MIME-Version:Content-Type:Subject:Date:Message-ID:From:To:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=kcFOWFD8i4PtYPSjVnPrffduYPILxeUG/iW9aiNhd/IJKzke6vNfdgr7vDyPox 2gkl6EX3lrqpvNNLU++a4nTbY/9k+yCuY27RKJPpAAsvl4HkDrNIoVu72/73GzuM kYyEE9u2ORfDvtKpoGCuo65D/Ys1WDSBSqXQSs5uBW6dk=; Received: (qmail 29005 invoked by alias); 14 Sep 2012 17:05:54 -0000 Received: (qmail 28991 invoked by uid 22791); 14 Sep 2012 17:05:52 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_20, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fw-tnat.cambridge.arm.com (HELO cam-smtp0.cambridge.arm.com) (217.140.96.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Sep 2012 17:05:13 +0000 Received: from geoffrey.Emea.Arm.com (geoffrey.emea.arm.com [10.1.255.46]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id q8EH5Bx6027596 for ; Fri, 14 Sep 2012 18:05:11 +0100 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: [PATCH, AArch64] Implement fnma, fms and fnms standard patterns Date: Fri, 14 Sep 2012 18:05:17 +0100 Message-ID: From: "Ian Bolton" To: X-IsSubscribed: yes 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 The following standard pattern names were implemented by simply renaming some existing patterns: * fnma * fms * fnms I have added an extra pattern for when we don't care about signed zero, so we can do "-fma (a,b,c)" more efficiently. Regression testing all passed. OK to commit? Cheers, Ian 2012-09-14 Ian Bolton gcc/ * config/aarch64/aarch64.md (fmsub4): Renamed to fnma4. * config/aarch64/aarch64.md (fnmsub4): Renamed to fms4. * config/aarch64/aarch64.md (fnmadd4): Renamed to fnms4. * config/aarch64/aarch64.md (*fnmadd4): New pattern. testsuite/ * gcc.target/aarch64/fmadd.c: Added extra tests. * gcc.target/aarch64/fnmadd-fastmath.c: New test. diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 3fbebf7..33815ff 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -2506,7 +2506,7 @@ (set_attr "mode" "")] ) -(define_insn "*fmsub4" +(define_insn "fnma4" [(set (match_operand:GPF 0 "register_operand" "=w") (fma:GPF (neg:GPF (match_operand:GPF 1 "register_operand" "w")) (match_operand:GPF 2 "register_operand" "w") @@ -2517,7 +2517,7 @@ (set_attr "mode" "")] ) -(define_insn "*fnmsub4" +(define_insn "fms4" [(set (match_operand:GPF 0 "register_operand" "=w") (fma:GPF (match_operand:GPF 1 "register_operand" "w") (match_operand:GPF 2 "register_operand" "w") @@ -2528,7 +2528,7 @@ (set_attr "mode" "")] ) -(define_insn "*fnmadd4" +(define_insn "fnms4" [(set (match_operand:GPF 0 "register_operand" "=w") (fma:GPF (neg:GPF (match_operand:GPF 1 "register_operand" "w")) (match_operand:GPF 2 "register_operand" "w") @@ -2539,6 +2539,18 @@ (set_attr "mode" "")] ) +;; If signed zeros are ignored, -(a * b + c) = -a * b - c. +(define_insn "*fnmadd4" + [(set (match_operand:GPF 0 "register_operand") + (neg:GPF (fma:GPF (match_operand:GPF 1 "register_operand") + (match_operand:GPF 2 "register_operand") + (match_operand:GPF 3 "register_operand"))))] + "!HONOR_SIGNED_ZEROS (mode) && TARGET_FLOAT" + "fnmadd\\t%0, %1, %2, %3" + [(set_attr "v8type" "fmadd") + (set_attr "mode" "")] +) + ;; ------------------------------------------------------------------- ;; Floating-point conversions ;; ------------------------------------------------------------------- diff --git a/gcc/testsuite/gcc.target/aarch64/fmadd.c b/gcc/testsuite/gcc.target/aarch64/fmadd.c index 3b55554..39975db 100644 --- a/gcc/testsuite/gcc.target/aarch64/fmadd.c +++ b/gcc/testsuite/gcc.target/aarch64/fmadd.c @@ -4,15 +4,52 @@ extern double fma (double, double, double); extern float fmaf (float, float, float); -double test1 (double x, double y, double z) +double test_fma1 (double x, double y, double z) { return fma (x, y, z); } -float test2 (float x, float y, float z) +float test_fma2 (float x, float y, float z) { return fmaf (x, y, z); } +double test_fnma1 (double x, double y, double z) +{ + return fma (-x, y, z); +} + +float test_fnma2 (float x, float y, float z) +{ + return fmaf (-x, y, z); +} + +double test_fms1 (double x, double y, double z) +{ + return fma (x, y, -z); +} + +float test_fms2 (float x, float y, float z) +{ + return fmaf (x, y, -z); +} + +double test_fnms1 (double x, double y, double z) +{ + return fma (-x, y, -z); +} + +float test_fnms2 (float x, float y, float z) +{ + return fmaf (-x, y, -z); +} + /* { dg-final { scan-assembler-times "fmadd\td\[0-9\]" 1 } } */ /* { dg-final { scan-assembler-times "fmadd\ts\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fmsub\td\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fmsub\ts\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fnmsub\td\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fnmsub\ts\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fnmadd\td\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fnmadd\ts\[0-9\]" 1 } } */ + diff --git a/gcc/testsuite/gcc.target/aarch64/fnmadd-fastmath.c b/gcc/testsuite/gcc.target/aarch64/fnmadd-fastmath.c new file mode 100644 index 0000000..9c115df --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fnmadd-fastmath.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double fma (double, double, double); +extern float fmaf (float, float, float); + +double test_fma1 (double x, double y, double z) +{ + return - fma (x, y, z); +} + +float test_fma2 (float x, float y, float z) +{ + return - fmaf (x, y, z); +} + +/* { dg-final { scan-assembler-times "fnmadd\td\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fnmadd\ts\[0-9\]" 1 } } */ +