This is the mail archive of the gcc-patches@gcc.gnu.org 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]

powerpc patch 4 of 9



It's best not to hint on PowerPC64 unless we're really sure;  Static
branch hints disable clever hardware branch history.  Note that this
changes PowerPC32 hint behaviour slightly for probabilies in the
range 0.45 to 0.55.  Previously we put out a "-" hint, now we give
no hint.  I don't think it matters either way..

	* config/rs6000/rs6000.c (output_cbranch): Don't hint for 64 bit
	targets unless highly probably/improbable.

Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.286
diff -u -p -r1.286 rs6000.c
--- rs6000.c	2002/02/19 02:53:36	1.286
+++ rs6000.c	2002/02/20 01:35:44
@@ -7188,21 +7221,28 @@ output_cbranch (op, label, reversed, ins
   
   /* 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 = "-";
+      int prob = INTVAL (XEXP (note, 0));
+
+      /* Only hint for highly probable/improbable branches on
+	 PowerPC64 as static prediction overrides processor dynamic
+	 prediction.  For PowerPC32 we may as well hint except for
+	 branches that are very close to 50%.  */
+      if (TARGET_POWERPC64
+	  ? (prob < REG_BR_PROB_BASE / 100 * 2
+	     || prob > REG_BR_PROB_BASE / 100 * 98)
+	  : (prob < REG_BR_PROB_BASE / 100 * 45
+	     || prob > REG_BR_PROB_BASE / 100 * 55))
+	{
+	  if ((prob > REG_BR_PROB_BASE / 2) ^ need_longbranch)
+	    pred = "+";
+	  else
+	    pred = "-";
+	}
     }
-  else
-    pred = "";
 
   if (label == NULL)
     s += sprintf (s, "{b%sr|b%slr%s} ", ccode, ccode, pred);
-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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