diff mbox

[SH] Fix defunct -mbranch-cost option

Message ID 1325099072.18753.625.camel@yam-132-YW-E178-FTW
State New
Headers show

Commit Message

Oleg Endo Dec. 28, 2011, 7:04 p.m. UTC
Hello,

while working on another PR I've noticed that the -mbranch-cost option
in the SH target is not really working.  The attached patch brings it
back to life, leaving the default behavior unchanged.

Cheers,
Oleg


2011-12-28  Oleg Endo  <oleg.endo@t-online.de>

	* config/sh/sh.h (BRANCH_COST): Use sh_branch_cost variable.
	* config/sh/sh.c (sh_option_override): Simplify sh_branch_cost
	expression.

Comments

Kaz Kojima Dec. 28, 2011, 10:20 p.m. UTC | #1
Oleg Endo <oleg.endo@t-online.de> wrote:
> while working on another PR I've noticed that the -mbranch-cost option
> in the SH target is not really working.  The attached patch brings it
> back to life, leaving the default behavior unchanged.
> 
> Cheers,
> Oleg
> 
> 
> 2011-12-28  Oleg Endo  <oleg.endo@t-online.de>
> 
> 	* config/sh/sh.h (BRANCH_COST): Use sh_branch_cost variable.
> 	* config/sh/sh.c (sh_option_override): Simplify sh_branch_cost
> 	expression.

Ok as the obvious fix.  Thanks for the patch.

Regards,
	kaz
diff mbox

Patch

Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	(revision 182695)
+++ gcc/config/sh/sh.c	(working copy)
@@ -724,9 +724,16 @@ 
   else
     sh_divsi3_libfunc = "__sdivsi3";
   if (sh_branch_cost == -1)
-    sh_branch_cost
-      = TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1;
+    {
+      sh_branch_cost = 1;
 
+      /*  The SH1 does not have delay slots, hence we get a pipeline stall
+	  at every branch.  The SH4 is superscalar, so the single delay slot
+	  is not sufficient to keep both pipelines filled.  */
+      if (! TARGET_SH2 || TARGET_HARD_SH4)
+	sh_branch_cost = 2;
+    }
+
   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if (! VALID_REGISTER_P (regno))
       sh_register_names[regno][0] = '\0';
Index: gcc/config/sh/sh.h
===================================================================
--- gcc/config/sh/sh.h	(revision 182695)
+++ gcc/config/sh/sh.h	(working copy)
@@ -2088,12 +2088,8 @@ 
    different code that does fewer memory accesses.  */
 
 /* A C expression for the cost of a branch instruction.  A value of 1
-   is the default; other values are interpreted relative to that.
-   The SH1 does not have delay slots, hence we get a pipeline stall
-   at every branch.  The SH4 is superscalar, so the single delay slot
-   is not sufficient to keep both pipelines filled.  */
-#define BRANCH_COST(speed_p, predictable_p) \
-	(TARGET_SH5 ? 1 : ! TARGET_SH2 || TARGET_HARD_SH4 ? 2 : 1)
+   is the default; other values are interpreted relative to that.  */
+#define BRANCH_COST(speed_p, predictable_p) sh_branch_cost
 
 /* Assembler output control.  */