From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123477 invoked by alias); 6 Jul 2015 08:20:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 121638 invoked by uid 89); 6 Jul 2015 08:20:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Jul 2015 08:20:45 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-15-Tdp6cOnkRT2r5Yv1ObS9yA-1 Received: from [10.2.207.49] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 6 Jul 2015 09:20:38 +0100 Message-ID: <559A3A57.3050304@arm.com> Date: Mon, 06 Jul 2015 08:20:00 -0000 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Ramana Radhakrishnan , Marcus Shawcroft Subject: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math X-MC-Unique: Tdp6cOnkRT2r5Yv1ObS9yA-1 Content-Type: multipart/mixed; boundary="------------000504000002090602000609" X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00300.txt.bz2 This is a multi-part message in MIME format. --------------000504000002090602000609 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-length: 694 fnmul was modeled as (-a)*b instead of -(a*b), which is wrong with -frounding-math, so the correct pattern is added too and the other one is only used if !flag_rounding_math. This affects a glibc math test, similar fix will be needed for ARM. Tested with aarch64-none-linux-gnu cross compiler. is this OK? gcc/Changelog: 2015-07-06 Szabolcs Nagy PR target/66731 * config/aarch64/aarch64.md (fnmul3): Handle -frounding-math. gcc/testsuite/Changelog: 2015-07-06 Szabolcs Nagy * gcc.target/aarch64/fnmul-1.c: New. * gcc.target/aarch64/fnmul-2.c: New. * gcc.target/aarch64/fnmul-3.c: New. * gcc.target/aarch64/fnmul-4.c: New. --------------000504000002090602000609 Content-Type: text/x-patch; name=fnmul-2.diff Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fnmul-2.diff" Content-length: 3189 diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 2d56a75..1e343fa 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -4175,6 +4175,16 @@ (mult:GPF (neg:GPF (match_operand:GPF 1 "register_operand" "w")) (match_operand:GPF 2 "register_operand" "w")))] + "TARGET_FLOAT && !flag_rounding_math" + "fnmul\\t%0, %1, %2" + [(set_attr "type" "fmul")] +) + +(define_insn "*fnmul3" + [(set (match_operand:GPF 0 "register_operand" "=3Dw") + (neg:GPF (mult:GPF + (match_operand:GPF 1 "register_operand" "w") + (match_operand:GPF 2 "register_operand" "w"))))] "TARGET_FLOAT" "fnmul\\t%0, %1, %2" [(set_attr "type" "fmul")] diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-1.c b/gcc/testsuite/gcc= .target/aarch64/fnmul-1.c new file mode 100644 index 0000000..7ec38e0 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +double +foo_d (double a, double b) +{ + /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" = } } */ + return -a * b; +} + +float +foo_s (float a, float b) +{ + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" = } } */ + return -a * b; +} diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-2.c b/gcc/testsuite/gcc= .target/aarch64/fnmul-2.c new file mode 100644 index 0000000..f05ee79 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -frounding-math" } */ + +double +foo_d (double a, double b) +{ + /* { dg-final { scan-assembler "fneg\\td\[0-9\]+, d\[0-9\]+" } } */ + /* { dg-final { scan-assembler "fmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" }= } */ + return -a * b; +} + +float +foo_s (float a, float b) +{ + /* { dg-final { scan-assembler "fneg\\ts\[0-9\]+, s\[0-9\]+" } } */ + /* { dg-final { scan-assembler "fmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" }= } */ + return -a * b; +} diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-3.c b/gcc/testsuite/gcc= .target/aarch64/fnmul-3.c new file mode 100644 index 0000000..301e9cd --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +double +foo_d (double a, double b) +{ + /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" = } } */ + return -(a * b); +} + +float +foo_s (float a, float b) +{ + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" = } } */ + return -(a * b); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-4.c b/gcc/testsuite/gcc= .target/aarch64/fnmul-4.c new file mode 100644 index 0000000..9b9bf1b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -frounding-math" } */ + +double +foo_d (double a, double b) +{ + /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" = } } */ + return -(a * b); +} + +float +foo_s (float a, float b) +{ + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" = } } */ + return -(a * b); +} --------------000504000002090602000609--