This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][AArch64] Properly cost MNEG/[SU]MNEGL patterns


Hi all,

Currently we do not handle the MNEG patterns properly in rtx costs.
These instructions are similar to the MSUB ones.
This patch handles them by catching the NEG at the appropriate position,
extracting its operands and letting the rest of the aarch64_rtx_mult_cost function
handle the additional costs.

Tested on aarch64-none-elf.

Ok trunk?

Thanks,
Kyrill

N.B.
This patches' context depends on:
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01049.html

2015-04-20  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * config/aarch64/aarch64.c (aarch64_rtx_mult_cost): Handle MNEG
    and [SU]MNEGL patterns.
commit 13b3a8297e6337a3ed89b9ef0182f273cf693ac3
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Tue Mar 10 15:52:24 2015 +0000

    [AArch64] Properly cost MNEG/[SU]MNEGL patterns

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 853cce9..d1635f4 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5228,6 +5228,15 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed)
 	  return cost;
 	}
 
+      /* MNEG or [US]MNEGL.  Extract the NEG operand and indicate that it's a
+	 compound and let the below cases handle it.  After all, MNEG is a
+	 special-case alias of MSUB.  */
+      if (GET_CODE (op0) == NEG)
+	{
+	  op0 = XEXP (op0, 0);
+	  compound_p = true;
+	}
+
       /* Integer multiplies or FMAs have zero/sign extending variants.  */
       if ((GET_CODE (op0) == ZERO_EXTEND
 	   && GET_CODE (op1) == ZERO_EXTEND)
@@ -5240,7 +5249,7 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed)
 	  if (speed)
 	    {
 	      if (compound_p)
-		/* MADD/SMADDL/UMADDL.  */
+		/* SMADDL/UMADDL/UMSUBL/SMSUBL.  */
 		cost += extra_cost->mult[0].extend_add;
 	      else
 		/* MUL/SMULL/UMULL.  */
@@ -5250,7 +5259,7 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed)
 	  return cost;
 	}
 
-      /* This is either an integer multiply or an FMA.  In both cases
+      /* This is either an integer multiply or a MADD.  In both cases
 	 we want to recurse and cost the operands.  */
       cost += rtx_cost (op0, MULT, 0, speed)
 	      + rtx_cost (op1, MULT, 1, speed);
@@ -5258,7 +5267,7 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed)
       if (speed)
 	{
 	  if (compound_p)
-	    /* MADD.  */
+	    /* MADD/MSUB.  */
 	    cost += extra_cost->mult[mode == DImode].add;
 	  else
 	    /* MUL.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]