This is the mail archive of the 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][ARM] PR60663: Improve RTX costs for asm statements

Hi all,

This patch relates to PR60663 where cse got confused due to asm statements being given a cost of zero in the arm backend. Jakub already put in a fix to cse for 4.9.0 ( but we should still fix the costs in arm.

This patch does that by estimating the number of instructions in the asm statement, adding the cost of the input operands and making sure that it's at least COSTS_N_INSNS (1).

Tested and bootstrapped on arm-none-linux-gnueabihf.

Ok for trunk?


2014-04-15  Kyrylo Tkachov  <>

	PR rtl-optimization/60663
	* config/arm/arm.c (arm_new_rtx_costs): Improve ASM_OPERANDS case,
	avoid 0 cost.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 91e4cd8..ce7ee82 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -10758,10 +10758,16 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
       return true;
     case ASM_OPERANDS:
-      /* Just a guess.  Cost one insn per input.  */
-      return true;
+      {
+      /* Just a guess.  Guess number of instructions in the asm
+         plus one insn per input.  Always a minimum of COSTS_N_INSNS (1)
+         though (see PR60663).  */
+        int asm_length = asm_str_count (ASM_OPERANDS_TEMPLATE (x));
+        int num_operands = ASM_OPERANDS_INPUT_LENGTH (x);
+        *cost = COSTS_N_INSNS (MAX (1, asm_length + num_operands));
+        return true;
+      }
       if (mode != VOIDmode)
 	*cost = COSTS_N_INSNS (ARM_NUM_REGS (mode));

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