diff mbox

[AArch64] PR target/66731 Fix fnmul insn with -frounding-math

Message ID 55A77844.7000702@arm.com
State New
Headers show

Commit Message

Szabolcs Nagy July 16, 2015, 9:24 a.m. UTC
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.

Comments

Szabolcs Nagy Aug. 4, 2015, 9:37 a.m. UTC | #1
On 16/07/15 10:24, Szabolcs Nagy wrote:
> 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.
>

ping.
James Greenhalgh Aug. 4, 2015, 9:54 a.m. UTC | #2
On Thu, Jul 16, 2015 at 10:24:20AM +0100, Szabolcs Nagy wrote:
> 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?

This is OK, sorry for the delay.

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

I see the ARM fixes went back to the release branches, so yes, a backport
would be appreciated.

Thanks,
James


> 
> 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.
diff mbox

Patch

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;