From f4857b9b42f3eb6c59e16c5422053533286d0255 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 2 Aug 2002 02:53:24 +0000 Subject: [PATCH] * config/rs6000/rs6000.c (output_cbranch): Hint differently for power4. From-SVN: r55967 --- gcc/ChangeLog | 4 ++++ gcc/config/rs6000/rs6000.c | 27 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 622bcf06cfb..f86aa87b6d6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2002-08-02 Alan Modra + + * config/rs6000/rs6000.c (output_cbranch): Hint differently for power4. + 2002-08-01 Daniel Jacobowitz * Makefile.in ($(BUILD_PREFIX_1)ggc-none.o): Use $(GGC_H). diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 932a60cb385..026e30f2c04 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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); -- 2.30.2