Patchwork [GCC/ARM] Fix rtx cost for Thumb1

login
register
mail settings
Submitter Bin Cheng
Date March 27, 2013, 8:22 a.m.
Message ID <003601ce2ac4$44487940$ccd96bc0$@cheng@arm.com>
Download mbox | patch
Permalink /patch/231607/
State New
Headers show

Comments

Bin Cheng - March 27, 2013, 8:22 a.m.
> -----Original Message-----
> From: Richard Earnshaw
> Sent: Tuesday, March 26, 2013 6:57 PM
> To: Bin Cheng
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH GCC/ARM]Fix rtx cost for Thumb1
> 
> On 26/03/13 08:34, Bin Cheng wrote:
> > Hi,
> > As reported in PR56102, arm back end returns wrong rtx cost for
> > pattern SET/ASHIFT/ASHIFTRT/LSHIFTRT/ROTATERT with multi-word mode.
> > This causes GCC skipping the split process in lower-subreg.c, and
> > generating bigger constant pool.
> >
> > This patch fixes the issue. Tested on arm-none-eabi/thumb1/O2/Os, ok
> > for trunk?
> >
> > Thanks.
> >
> > 2013-03-26  Bin Cheng  <bin.cheng@arm.com>
> >
> > 	PR target/56102
> > 	* config/arm/arm.c (thumb1_rtx_costs, thumb1_size_rtx_costs): Fix
> > 	rtx costs for SET/ASHIFT/ASHIFTRT/LSHIFTRT/ROTATERT patterns with
> > 	mult-word mode.
> >
> 

Sorry that I mis-sent the old version patch. The right one is attached now.
Since the difference is obvious and was approved before this thread, I
committed it directly as revision 197155.

Thanks.

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 197154)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2013-03-27  Bin Cheng  <bin.cheng@arm.com>
+
+	PR target/56102
+	* config/arm/arm.c (thumb1_rtx_costs, thumb1_size_rtx_costs): Fix
+	rtx costs for SET/ASHIFT/ASHIFTRT/LSHIFTRT/ROTATERT patterns with
+	mult-word mode.
+
 2013-03-27  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
 	* config/s390/s390.h (TARGET_FLT_EVAL_METHOD): Define.
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 197154)
+++ gcc/config/arm/arm.c	(working copy)
@@ -7116,7 +7116,7 @@  static inline int
 thumb1_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer)
 {
   enum machine_mode mode = GET_MODE (x);
-  int total;
+  int total, words;
 
   switch (code)
     {
@@ -7124,6 +7124,8 @@  thumb1_rtx_costs (rtx x, enum rtx_code code, enum
     case ASHIFTRT:
     case LSHIFTRT:
     case ROTATERT:
+      return (mode == SImode) ? COSTS_N_INSNS (1) : COSTS_N_INSNS (2);
+
     case PLUS:
     case MINUS:
     case COMPARE:
@@ -7147,7 +7149,10 @@  thumb1_rtx_costs (rtx x, enum rtx_code code, enum
       return COSTS_N_INSNS (1) + 16;
 
     case SET:
-      return (COSTS_N_INSNS (1)
+      /* A SET doesn't have a mode, so let's look at the SET_DEST to get
+	 the mode.  */
+      words = ARM_NUM_INTS (GET_MODE_SIZE (GET_MODE (SET_DEST (x))));
+      return (COSTS_N_INSNS (words)
 	      + 4 * ((MEM_P (SET_SRC (x)))
 		     + MEM_P (SET_DEST (x))));
 
@@ -7844,6 +7849,7 @@  static inline int
 thumb1_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer)
 {
   enum machine_mode mode = GET_MODE (x);
+  int words;
 
   switch (code)
     {
@@ -7851,6 +7857,8 @@  thumb1_size_rtx_costs (rtx x, enum rtx_code code,
     case ASHIFTRT:
     case LSHIFTRT:
     case ROTATERT:
+      return (mode == SImode) ? COSTS_N_INSNS (1) : COSTS_N_INSNS (2);
+
     case PLUS:
     case MINUS:
     case COMPARE:
@@ -7869,7 +7877,10 @@  thumb1_size_rtx_costs (rtx x, enum rtx_code code,
       return COSTS_N_INSNS (1);
 
     case SET:
-      return (COSTS_N_INSNS (1)
+      /* A SET doesn't have a mode, so let's look at the SET_DEST to get
+	 the mode.  */
+      words = ARM_NUM_INTS (GET_MODE_SIZE (GET_MODE (SET_DEST (x))));
+      return (COSTS_N_INSNS (words)
               + 4 * ((MEM_P (SET_SRC (x)))
                      + MEM_P (SET_DEST (x))));