public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: James Greenhalgh <james.greenhalgh@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
	Marcus Shawcroft <Marcus.Shawcroft@arm.com>
Subject: Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
Date: Thu, 16 Jul 2015 10:11:00 -0000	[thread overview]
Message-ID: <55A77844.7000702@arm.com> (raw)
In-Reply-To: <20150706102438.GA2102@arm.com>

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

On 06/07/15 11:24, James Greenhalgh wrote:
> 
> Please make sure in a follow-up patch that the costing logic in
> aarch64_rtx_costs also gets updated.
> 

Tested with aarch64-none-linux-gnu cross compiler.
is this OK?

i assume i should backport the fnmul fixes to the gcc-5 branch.

2015-07-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/aarch64/aarch64.c (aarch64_rtx_costs): Fix NEG cost for FNMUL.
	(aarch64_rtx_mult_cost): Fix MULT cost with -frounding-math.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fnmul-cost.diff --]
[-- Type: text/x-patch; name=fnmul-cost.diff, Size: 1398 bytes --]

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 6c13a078..1a3d6be 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5435,11 +5435,17 @@ aarch64_rtx_mult_cost (rtx x, enum rtx_code code, int outer, bool speed)
       if (speed)
 	{
 	  /* Floating-point FMA/FMUL can also support negations of the
-	     operands.  */
-	  if (GET_CODE (op0) == NEG)
-	    op0 = XEXP (op0, 0);
-	  if (GET_CODE (op1) == NEG)
-	    op1 = XEXP (op1, 0);
+	     operands, unless the rounding mode is upward or downward in
+	     which case FNMUL is different than FMUL with operand negation.  */
+	  bool neg0 = GET_CODE (op0) == NEG;
+	  bool neg1 = GET_CODE (op1) == NEG;
+	  if (compound_p || !flag_rounding_math || (neg0 && neg1))
+	    {
+	      if (neg0)
+		op0 = XEXP (op0, 0);
+	      if (neg1)
+		op1 = XEXP (op1, 0);
+	    }
 
 	  if (compound_p)
 	    /* FMADD/FNMADD/FNMSUB/FMSUB.  */
@@ -5956,6 +5962,12 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED,
 	      *cost = rtx_cost (op0, mode, NEG, 0, speed);
               return true;
             }
+	  if (GET_CODE (op0) == MULT)
+	    {
+	      /* FNMUL.  */
+	      *cost = rtx_cost (op0, mode, NEG, 0, speed);
+	      return true;
+	    }
 	  if (speed)
 	    /* FNEG.  */
 	    *cost += extra_cost->fp[mode == DFmode].neg;

  reply	other threads:[~2015-07-16  9:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06  8:20 Szabolcs Nagy
2015-07-06 10:24 ` James Greenhalgh
2015-07-16 10:11   ` Szabolcs Nagy [this message]
2015-08-04  9:37     ` Szabolcs Nagy
2015-08-04  9:55     ` James Greenhalgh
2015-07-06 15:39 ` Marcus Shawcroft
2015-07-09 14:40   ` Szabolcs Nagy
2015-07-15  8:34     ` Ramana Radhakrishnan
2015-07-15  9:26       ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A77844.7000702@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=Marcus.Shawcroft@arm.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).