Hi. Following patch fixes a typo in first match heuristics that blocks selection of best first match heuristics.
It's questionable whether to add a spacial test-case for that? I'm bit concerned that it can be a bit fragile. Bootstrapped and regtested on x86_64-linux. Ready for trunk? Thanks, Martin
>From 4106928c3eea80c732d32d73d653525c698515d6 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Thu, 2 Jun 2016 11:51:57 +0200 Subject: [PATCH] Fix first match heuristics gcc/ChangeLog: 2016-06-02 Martin Liska <mli...@suse.cz> * predict.c (combine_predictions_for_bb): Fix first match in cases where a first predictor contains more than one occurence in list of predictors. Take the best value in such case. gcc/testsuite/ChangeLog: 2016-06-02 Martin Liska <mli...@suse.cz> * gcc.dg/predict-9.c: New test. --- gcc/predict.c | 2 +- gcc/testsuite/gcc.dg/predict-9.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/predict-9.c diff --git a/gcc/predict.c b/gcc/predict.c index e9dda20..429f44e 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -939,7 +939,7 @@ combine_predictions_for_bb (basic_block bb, bool dry_run) pred2; pred2 = pred2->ep_next) if (pred2 != pred && pred2->ep_predictor == pred->ep_predictor) { - int probability2 = pred->ep_probability; + int probability2 = pred2->ep_probability; if (pred2->ep_edge != first) probability2 = REG_BR_PROB_BASE - probability2; diff --git a/gcc/testsuite/gcc.dg/predict-9.c b/gcc/testsuite/gcc.dg/predict-9.c new file mode 100644 index 0000000..59be16e --- /dev/null +++ b/gcc/testsuite/gcc.dg/predict-9.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; +extern int global2; +extern int global3; + +void foo (int base) +{ + int i; + while (global < 10) + { + if(global || global2 || global3) + return; + + for (i = base; i < 10; i++) + if (i > 123) + return; + } +} + +/* { dg-final { scan-tree-dump-times "first match heuristics: 2.0%" 4 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "first match heuristics: 4.5%" 0 "profile_estimate"} } */ -- 2.8.3