Patchwork Fix thumb1 size cost of small constants

login
register
mail settings
Submitter Maxim Kuvyrkov
Date June 23, 2010, 9:05 p.m.
Message ID <4C22771B.9000904@codesourcery.com>
Download mbox | patch
Permalink /patch/56719/
State New
Headers show

Comments

Maxim Kuvyrkov - June 23, 2010, 9:05 p.m.
This patch fixes thumb1 size cost of small constants.

Currently, the cost of SET of a constant is set to zero, which is odd 
considering that it still takes one instruction to do the operation. 
The code for Thumb2 and ARM modes returns COSTS_N_INSNS (1) for similar 
case, so the patch makes Thumb1 cost agree with ARM and Thumb2 cost.

OK to check in?

Thank you,
Richard Earnshaw - June 24, 2010, 10:22 a.m.
On Thu, 2010-06-24 at 01:05 +0400, Maxim Kuvyrkov wrote:
> This patch fixes thumb1 size cost of small constants.
> 
> Currently, the cost of SET of a constant is set to zero, which is odd 
> considering that it still takes one instruction to do the operation. 
> The code for Thumb2 and ARM modes returns COSTS_N_INSNS (1) for similar 
> case, so the patch makes Thumb1 cost agree with ARM and Thumb2 cost.
> 
> OK to check in?
> 
> Thank you,

OK.

R.

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index d846557..b2186d8 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -6941,7 +6941,7 @@  thumb1_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer)
       if (outer == SET)
         {
           if ((unsigned HOST_WIDE_INT) INTVAL (x) < 256)
-            return 0;
+            return COSTS_N_INSNS (1);
 	  /* See split "TARGET_THUMB1 && satisfies_constraint_J".  */
 	  if (INTVAL (x) >= -255 && INTVAL (x) <= -1)
             return COSTS_N_INSNS (2);