diff mbox

[x86] fix FMA cost computation

Message ID orboyk33j3.fsf@livre.localdomain
State New
Headers show

Commit Message

Alexandre Oliva May 30, 2011, 10:07 a.m. UTC
One of my patches for PR48866 mysteriously regressed fma3-fma.c.  It
turned out that a rearrangement in the order of emitting insns during
expansion caused combine to attempt combinations in a different order,
and this ended up exposing a latent error in the cost computation of FMA
insns, that caused a desirable combination to be regarded as not
profitable.  The problem was that, when stripping out NEGs from
operands, that would be costless in FMA variants, we took the
sub-operand from the wrong variable.  Oops.

I took the opportunity to fix the names of the fma_fnm* patterns, that
were missing the ā€œnā€.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

Comments

Bernd Schmidt May 30, 2011, 10:28 a.m. UTC | #1
On 05/30/2011 12:07 PM, Alexandre Oliva wrote:
> One of my patches for PR48866 mysteriously regressed fma3-fma.c.  It
> turned out that a rearrangement in the order of emitting insns during
> expansion caused combine to attempt combinations in a different order,
> and this ended up exposing a latent error in the cost computation of FMA
> insns, that caused a desirable combination to be regarded as not
> profitable.  The problem was that, when stripping out NEGs from
> operands, that would be costless in FMA variants, we took the
> sub-operand from the wrong variable.  Oops.
> 
> I took the opportunity to fix the names of the fma_fnm* patterns, that
> were missing the ā€œnā€.
> 
> Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

Ok.


Bernd
diff mbox

Patch

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/i386/i386.c (ix86_rtx_costs): Drop NEG from sub for FMA.
	* config/i386/sse.md: Add n to negated FMA pattern names.

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c.orig	2011-05-26 05:03:11.755995482 -0300
+++ gcc/config/i386/i386.c	2011-05-26 05:03:20.639013123 -0300
@@ -29231,12 +29231,12 @@  ix86_rtx_costs (rtx x, int code, int out
         /* Negate in op0 or op2 is free: FMS, FNMA, FNMS.  */
 	sub = XEXP (x, 0);
 	if (GET_CODE (sub) == NEG)
-	  sub = XEXP (x, 0);
+	  sub = XEXP (sub, 0);
 	*total += rtx_cost (sub, FMA, speed);
 
 	sub = XEXP (x, 2);
 	if (GET_CODE (sub) == NEG)
-	  sub = XEXP (x, 0);
+	  sub = XEXP (sub, 0);
 	*total += rtx_cost (sub, FMA, speed);
 	return true;
       }
Index: gcc/config/i386/sse.md
===================================================================
--- gcc/config/i386/sse.md.orig	2011-05-26 05:03:11.755995482 -0300
+++ gcc/config/i386/sse.md	2011-05-26 05:03:20.642013129 -0300
@@ -1731,7 +1731,7 @@ 
   [(set_attr "type" "ssemuladd")
    (set_attr "mode" "<MODE>")])
 
-(define_insn "*fma_fmadd_<mode>"
+(define_insn "*fma_fnmadd_<mode>"
   [(set (match_operand:FMAMODE 0 "register_operand" "=x,x,x")
 	(fma:FMAMODE
 	  (neg:FMAMODE
@@ -1746,7 +1746,7 @@ 
   [(set_attr "type" "ssemuladd")
    (set_attr "mode" "<MODE>")])
 
-(define_insn "*fma_fmsub_<mode>"
+(define_insn "*fma_fnmsub_<mode>"
   [(set (match_operand:FMAMODE 0 "register_operand" "=x,x,x")
 	(fma:FMAMODE
 	  (neg:FMAMODE