From patchwork Mon Jul 6 08:20:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 491458 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A88B0140781 for ; Mon, 6 Jul 2015 18:20:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=H02jP4BF; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=EBQC/VxffIF6vOcSNq7Nl/VQOv6oOMRYXhNAjisg6T1 Yhap5mfl240ZyK3S7MECVjCn0UN9I4Mn/yGUNMMhmz3t4DXYt1od4qwpGCbwOM8v 49siJ8ltgMBXR8uCv6QHE+d9Xf7+HM8r3W5TMEBv2WIFS0kaYUJcrTJkBhuhgzcs = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=23xeLdRRqS5+kanRezGlfcRaAiI=; b=H02jP4BFo5RZPIuUg Gg2FdA2++qaJpFmYJbtowu4JoM5Eh4hWtmHQvwDUXDnVLEyRDlcJ2g77yLWrlJFR jkMqyH9yq8DTaL3MiDv5wunQB/2QeGm4KhFwUdVAwx7BkFWaZHaXD5juuTy0ZMKJ 82VQs+kMoHoP3MWHsWM/EjqCQE= 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-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 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 09:20:39 +0100 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 X-IsSubscribed: yes 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. 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" "=w") + (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); +}