summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-13 14:32:06 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-13 14:32:06 +0000
commit49d7c0dbd77c9bcba419156216a7293dfad1c926 (patch)
treee59eac6e05b87df267c8abeecdbcfcb5365cb8a4 /gcc
parentb51f29b9a0c6c439e4c9b673ed79c0c6852ae518 (diff)
downloadgcc-49d7c0dbd77c9bcba419156216a7293dfad1c926.tar.gz
* predict.c (dump_prediction): New argument "USED".
(combine_predictions_for_insn): Determine the used heuristics, output the case no heuristic applied. * predict.def (PRED_DS_THEORY, PRED_NO_HEURISTIC): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44853 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/predict.c60
-rw-r--r--gcc/predict.def8
3 files changed, 61 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e2349b2455a..bdb2afc6d24 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+Mon Aug 13 02:27:39 CEST 2001 Jan Hubicka <jh@suse.cz>
+
+ * predict.c (dump_prediction): New argument "USED".
+ (combine_predictions_for_insn): Determine the used heuristics,
+ output the case no heuristic applied.
+ * predict.def (PRED_DS_THEORY, PRED_NO_HEURISTIC): New.
+
2001-08-13 Andreas Jaeger <aj@suse.de>
* config/i386/unix.h (ASM_OUTPUT_MI_THUNK): Don't capitalize
diff --git a/gcc/predict.c b/gcc/predict.c
index 128556c4819..06829ddb554 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -59,7 +59,7 @@
static void combine_predictions_for_insn PARAMS ((rtx, basic_block));
static void dump_prediction PARAMS ((enum br_predictor, int,
- basic_block));
+ basic_block, bool));
static void estimate_loops_at_level PARAMS ((struct loop *loop));
static void propagate_freq PARAMS ((basic_block));
static void estimate_bb_frequencies PARAMS ((struct loops *));
@@ -178,10 +178,11 @@ invert_br_probabilities (insn)
/* Dump information about the branch prediction to the output file. */
static void
-dump_prediction (predictor, probability, bb)
+dump_prediction (predictor, probability, bb, used)
enum br_predictor predictor;
int probability;
basic_block bb;
+ bool used;
{
edge e = bb->succ;
@@ -191,8 +192,9 @@ dump_prediction (predictor, probability, bb)
while (e->flags & EDGE_FALLTHRU)
e = e->succ_next;
- fprintf (rtl_dump_file, " %s heuristics: %.1f%%",
+ fprintf (rtl_dump_file, " %s heuristics%s: %.1f%%",
predictor_info[predictor].name,
+ used ? "" : " (ignored)",
probability * 100.0 / REG_BR_PROB_BASE);
if (bb->count)
@@ -218,10 +220,13 @@ combine_predictions_for_insn (insn, bb)
{
rtx prob_note = find_reg_note (insn, REG_BR_PROB, 0);
rtx *pnote = &REG_NOTES (insn);
+ rtx note = REG_NOTES (insn);
int best_probability = PROB_EVEN;
int best_predictor = END_PREDICTORS;
int combined_probability = REG_BR_PROB_BASE / 2;
int d;
+ bool first_match = false;
+ bool found = false;
if (rtl_dump_file)
fprintf (rtl_dump_file, "Predictions for insn %i bb %i\n", INSN_UID (insn),
@@ -230,17 +235,16 @@ combine_predictions_for_insn (insn, bb)
/* We implement "first match" heuristics and use probability guessed
by predictor with smallest index. In the future we will use better
probability combination techniques. */
- while (*pnote)
+ while (note)
{
- if (REG_NOTE_KIND (*pnote) == REG_BR_PRED)
+ if (REG_NOTE_KIND (note) == REG_BR_PRED)
{
- int predictor = INTVAL (XEXP (XEXP (*pnote, 0), 0));
- int probability = INTVAL (XEXP (XEXP (*pnote, 0), 1));
+ int predictor = INTVAL (XEXP (XEXP (note, 0), 0));
+ int probability = INTVAL (XEXP (XEXP (note, 0), 1));
- dump_prediction (predictor, probability, bb);
+ found = true;
if (best_predictor > predictor)
best_probability = probability, best_predictor = predictor;
- *pnote = XEXP (*pnote, 1);
d = (combined_probability * probability
+ (REG_BR_PROB_BASE - combined_probability)
@@ -249,13 +253,43 @@ combine_predictions_for_insn (insn, bb)
combined_probability = (((double)combined_probability) * probability
* REG_BR_PROB_BASE / d + 0.5);
}
- else
- pnote = &XEXP (*pnote, 1);
+ note = XEXP (note, 1);
}
+
+ /* Decide heuristic to use. In case we didn't match anything, use
+ no_prediction heuristic, in case we did match, use either
+ first match or Dempster-Shaffer theory depending on the flags. */
+
if (predictor_info [best_predictor].flags & PRED_FLAG_FIRST_MATCH)
+ first_match = true;
+
+ if (!found)
+ dump_prediction (PRED_NO_PREDICTION, combined_probability, bb, true);
+ else
+ {
+ dump_prediction (PRED_DS_THEORY, combined_probability, bb,
+ !first_match);
+ dump_prediction (PRED_FIRST_MATCH, best_probability, bb, first_match);
+ }
+
+ if (first_match)
combined_probability = best_probability;
- dump_prediction (PRED_FIRST_MATCH, best_probability, bb);
- dump_prediction (PRED_COMBINED, combined_probability, bb);
+ dump_prediction (PRED_COMBINED, combined_probability, bb, true);
+
+ while (*pnote)
+ {
+ if (REG_NOTE_KIND (*pnote) == REG_BR_PRED)
+ {
+ int predictor = INTVAL (XEXP (XEXP (*pnote, 0), 0));
+ int probability = INTVAL (XEXP (XEXP (*pnote, 0), 1));
+
+ dump_prediction (predictor, probability, bb,
+ !first_match || best_predictor == predictor);
+ *pnote = XEXP (*pnote, 1);
+ }
+ else
+ pnote = &XEXP (*pnote, 1);
+ }
if (!prob_note)
{
REG_NOTES (insn)
diff --git a/gcc/predict.def b/gcc/predict.def
index 7559a12f477..a4f7afb05d5 100644
--- a/gcc/predict.def
+++ b/gcc/predict.def
@@ -36,13 +36,19 @@ Boston, MA 02111-1307, USA. */
REG_BR_PROB_BASE / 2). */
-/* An combined heuristics using Dempster-Shaffer theory. */
+/* A value used as final outcome of all heuristics. */
DEF_PREDICTOR (PRED_COMBINED, "combined", PROB_ALWAYS, 0)
+/* An outcome estimated by Dempster-Shaffer theory. */
+DEF_PREDICTOR (PRED_DS_THEORY, "DS theory", PROB_ALWAYS, 0)
+
/* An combined heuristics using probability determined by first
matching heuristics from this list. */
DEF_PREDICTOR (PRED_FIRST_MATCH, "first match", PROB_ALWAYS, 0)
+/* Heuristic applying when no heuristic bellow applies. */
+DEF_PREDICTOR (PRED_NO_PREDICTION, "no prediction", PROB_ALWAYS, 0)
+
/* Mark unconditional jump as taken. */
DEF_PREDICTOR (PRED_UNCONDITIONAL, "unconditional jump", PROB_ALWAYS,
PRED_FLAG_FIRST_MATCH)