* config/rs6000/rs6000.c (output_cbranch): Hint differently for power4.
authorAlan Modra <amodra@bigpond.net.au>
Fri, 2 Aug 2002 02:53:24 +0000 (02:53 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Fri, 2 Aug 2002 02:53:24 +0000 (12:23 +0930)
From-SVN: r55967

gcc/ChangeLog
gcc/config/rs6000/rs6000.c

index 622bcf06cfb7f92e1b5695ecf488ea61c5456838..f86aa87b6d6a444a5b2e4b7d101141b199a1dc72 100644 (file)
@@ -1,3 +1,7 @@
+2002-08-02  Alan Modra  <amodra@bigpond.net.au>
+
+       * config/rs6000/rs6000.c (output_cbranch): Hint differently for power4.
+
 2002-08-01  Daniel Jacobowitz  <drow@mvista.com>
 
        * Makefile.in ($(BUILD_PREFIX_1)ggc-none.o): Use $(GGC_H).
index 932a60cb385808682f116b42daa63e93735203d4..026e30f2c042ea01002813e92e1cf06e52294dd7 100644 (file)
@@ -8438,21 +8438,30 @@ output_cbranch (op, label, reversed, insn)
   
   /* Maybe we have a guess as to how likely the branch is.  
      The old mnemonics don't have a way to specify this information.  */
+  pred = "";
   note = find_reg_note (insn, REG_BR_PROB, NULL_RTX);
   if (note != NULL_RTX)
     {
       /* PROB is the difference from 50%.  */
       int prob = INTVAL (XEXP (note, 0)) - REG_BR_PROB_BASE / 2;
-      
-      /* For branches that are very close to 50%, assume not-taken.  */
-      if (abs (prob) > REG_BR_PROB_BASE / 20
-         && ((prob > 0) ^ need_longbranch))
-       pred = "+";
-      else
-       pred = "-";
+      bool always_hint = rs6000_cpu != PROCESSOR_POWER4;
+
+      /* Only hint for highly probable/improbable branches on newer
+        cpus as static prediction overrides processor dynamic
+        prediction.  For older cpus we may as well always hint, but
+        assume not taken for branches that are very close to 50% as a
+        mispredicted taken branch is more expensive than a
+        mispredicted not-taken branch.  */ 
+      if (always_hint
+         || abs (prob) > REG_BR_PROB_BASE / 100 * 48)
+       {
+         if (abs (prob) > REG_BR_PROB_BASE / 20
+             && ((prob > 0) ^ need_longbranch))
+           pred = "+";
+         else
+           pred = "-";
+       }
     }
-  else
-    pred = "";
 
   if (label == NULL)
     s += sprintf (s, "{b%sr|b%slr%s} ", ccode, ccode, pred);