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]

Re: PATCH: tune ARM's rtx_costs function


> This needs to be reformatted according to GNU coding standards.

Here are the re-formatted patches.  OK to commit?

 
2003-07-07  James Lemke <jim@wasabisystems.com>
 
	* config/arm/arm.c (arm_rtx_costs): Improve for xscale multiply.
	* config/arm/arm.md (addsi3): Use new pseudo.
	* testsuite/gcc.dg/arm-g2.c: New file.

Index: config/arm/arm.c
===================================================================
RCS file: /cvsroot/gnu/gcc/config/arm/arm.c,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.5
diff -u -r1.3.2.3 -r1.3.2.5
--- config/arm/arm.c	1 Oct 2003 13:48:38 -0000	1.3.2.3
+++ config/arm/arm.c	3 Oct 2003 16:37:36 -0000	1.3.2.5
@@ -2838,19 +2838,44 @@
 	{
 	  unsigned HOST_WIDE_INT i = (INTVAL (XEXP (x, 1))
 				      & (unsigned HOST_WIDE_INT) 0xffffffff);
-	  int add_cost = const_ok_for_arm (i) ? 4 : 8;
-	  int j;
+	  int cost, const_ok = const_ok_for_arm (i);
+	  int j, booth_unit_size;
 	  
+	  if (arm_is_xscale)
+	    {
+	      unsigned HOST_WIDE_INT masked_const;
+
+	      /* The cost will be related to two insns.
+		 First a load of the constant (MOV or LDR), then a multiply. */
+	      cost = 2;
+	      if (! const_ok)
+		  cost += 1;	/* LDR is probably more expensive because
+		  		   of longer result latency. */
+	      masked_const = i & 0xFfff8000UL;
+	      if (masked_const == 0UL || masked_const == 0xFfff8000UL)
+		  ;
+	      else
+		{
+	          masked_const = i & 0xF8000000UL;
+	          if (masked_const == 0UL || masked_const == 0xF8000000UL)
+		      cost += 1;
+	          else
+		      cost += 2;
+		}
+	      return cost;
+	    }
+
 	  /* Tune as appropriate.  */ 
-	  int booth_unit_size = ((tune_flags & FL_FAST_MULT) ? 8 : 2);
+	  cost = const_ok ? 4 : 8;
+	  booth_unit_size = ((tune_flags & FL_FAST_MULT) ? 8 : 2);
 	  
 	  for (j = 0; i && j < 32; j += booth_unit_size)
 	    {
 	      i >>= booth_unit_size;
-	      add_cost += 2;
+	      cost += 2;
 	    }
 
-	  return add_cost;
+	  return cost;
 	}
 
       return (((tune_flags & FL_FAST_MULT) ? 8 : 30)

Index: config/arm/arm.md
===================================================================
RCS file: /cvsroot/gnu/gcc/config/arm/arm.md,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -r1.3.2.4 -r1.3.2.5
--- config/arm/arm.md	1 Oct 2003 12:44:08 -0000	1.3.2.4
+++ config/arm/arm.md	2 Oct 2003 17:38:10 -0000	1.3.2.5
@@ -531,8 +531,7 @@
   if (TARGET_ARM && GET_CODE (operands[2]) == CONST_INT)
     {
       arm_split_constant (PLUS, SImode, INTVAL (operands[2]), operands[0],
-			  operands[1],
-			  (no_new_pseudos ? 0 : preserve_subexpressions_p ()));
+			  operands[1], ! no_new_pseudos);
       DONE;
     }
   "

And the new file: gcc/testsuite/gcc.dg/arm-g2.c
===================================================================
/* Verify that hardware multiply is preferred on XScale. */
/* { dg-do compile { target xscale*-*-* } } */
/* { dg-options "-mcpu=xscale -O" } */

/* Brett Gaines' test case. */
unsigned BCPL(unsigned) __attribute__ ((naked));
unsigned BCPL(unsigned seed)
{
    /* Best code would be:
       ldr r1, =2147001325
       ldr r2, =715136305
       mla r0, r1, r0, r2
       mov pc, lr */

    return seed * 2147001325U + 715136305U;
}

/* We want to suppress running for -mthumb but not for -mthumb-interwork. */
/* { dg-final { global compiler_flags; if ![string match "*-mthumb *" $compiler_
flags] { scan-assembler "mla\[  ].*" } } } */

-- 
James Lemke   jim@wasabisystems.com   Orillia, Ontario
http://www.wasabisystems.com


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