aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-06-21 14:52:14 +0200
committerMartin Liska <marxin@gcc.gnu.org>2017-06-21 12:52:14 +0000
commit93c18375823fdd0e384f673f75e39136719135dd (patch)
treed25acabcbf72c143c997ccd8e7b212c5930584ad /gcc
parente59a1c22fb249388e82b4fd004f33615abe36d2e (diff)
downloadgcc-93c18375823fdd0e384f673f75e39136719135dd.zip
gcc-93c18375823fdd0e384f673f75e39136719135dd.tar.gz
gcc-93c18375823fdd0e384f673f75e39136719135dd.tar.bz2
Rework cold and hot label attributes in predict.c.
2017-06-21 Martin Liska <mliska@suse.cz> * gimplify.c (gimplify_label_expr): Insert GIMPLE_PREDICT statements on cold and hot labels. * predict.c (tree_estimate_probability_bb): Remove the prediction from this place. 2017-06-21 Martin Liska <mliska@suse.cz> * gcc.dg/tree-ssa/attr-hotcold-2.c: Update scanned patterns. From-SVN: r249451
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimplify.c10
-rw-r--r--gcc/predict.c23
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c4
5 files changed, 22 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 12d0ee8..2308d35 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2017-06-21 Martin Liska <mliska@suse.cz>
+ * gimplify.c (gimplify_label_expr): Insert GIMPLE_PREDICT
+ statements on cold and hot labels.
+ * predict.c (tree_estimate_probability_bb): Remove the
+ prediction from this place.
+
+2017-06-21 Martin Liska <mliska@suse.cz>
+
PR tree-optimization/79489
* gimplify.c (maybe_add_early_return_predict_stmt): New
function.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c645bce..641a821 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2357,10 +2357,18 @@ gimplify_label_expr (tree *expr_p, gimple_seq *pre_p)
gcc_assert (decl_function_context (LABEL_EXPR_LABEL (*expr_p))
== current_function_decl);
- glabel *label_stmt = gimple_build_label (LABEL_EXPR_LABEL (*expr_p));
+ tree label = LABEL_EXPR_LABEL (*expr_p);
+ glabel *label_stmt = gimple_build_label (label);
gimple_set_location (label_stmt, EXPR_LOCATION (*expr_p));
gimplify_seq_add_stmt (pre_p, label_stmt);
+ if (lookup_attribute ("cold", DECL_ATTRIBUTES (label)))
+ gimple_seq_add_stmt (pre_p, gimple_build_predict (PRED_COLD_LABEL,
+ NOT_TAKEN));
+ else if (lookup_attribute ("hot", DECL_ATTRIBUTES (label)))
+ gimple_seq_add_stmt (pre_p, gimple_build_predict (PRED_HOT_LABEL,
+ TAKEN));
+
return GS_ALL_DONE;
}
diff --git a/gcc/predict.c b/gcc/predict.c
index 790be9f..44151bc 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2742,29 +2742,6 @@ tree_estimate_probability_bb (basic_block bb, bool local_only)
FOR_EACH_EDGE (e, ei, bb->succs)
{
- /* Predict edges to user labels with attributes. */
- if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
- {
- gimple_stmt_iterator gi;
- for (gi = gsi_start_bb (e->dest); !gsi_end_p (gi); gsi_next (&gi))
- {
- glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gi));
- tree decl;
-
- if (!label_stmt)
- break;
- decl = gimple_label_label (label_stmt);
- if (DECL_ARTIFICIAL (decl))
- continue;
-
- /* Finally, we have a user-defined label. */
- if (lookup_attribute ("cold", DECL_ATTRIBUTES (decl)))
- predict_edge_def (e, PRED_COLD_LABEL, NOT_TAKEN);
- else if (lookup_attribute ("hot", DECL_ATTRIBUTES (decl)))
- predict_edge_def (e, PRED_HOT_LABEL, TAKEN);
- }
- }
-
/* Look for block we are guarding (ie we dominate it,
but it doesn't postdominate us). */
if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && e->dest != bb
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a31bba4..b45fc57 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-06-21 Martin Liska <mliska@suse.cz>
+
+ * gcc.dg/tree-ssa/attr-hotcold-2.c: Update scanned patterns.
+
2017-06-21 Pierre-Marie de Rodat <derodat@adacore.com>
* gnat.dg/debug11_pkg.adb, gnat.dg/debug11_pkg.ads,
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c
index f7a5098..184dd10 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c
@@ -20,9 +20,9 @@ void f(int x, int y)
/* { dg-final { scan-tree-dump-times "hot label heuristics" 1 "profile_estimate" } } */
/* { dg-final { scan-tree-dump-times "cold label heuristics" 1 "profile_estimate" } } */
-/* { dg-final { scan-tree-dump-times "block 4, loop depth 0, freq \[1-4\]\[^0-9\]" 3 "profile_estimate" } } */
+/* { dg-final { scan-tree-dump "A \\\[0\\\..*\\\]" "profile_estimate" } } */
/* Note: we're attempting to match some number > 6000, i.e. > 60%.
The exact number ought to be tweekable without having to juggle
the testcase around too much. */
-/* { dg-final { scan-tree-dump-times "block 5, loop depth 0, freq \[6-9\]\[0-9\]\[0-9\]\[0-9\]" 3 "profile_estimate" } } */
+/* { dg-final { scan-tree-dump "B \\\[\[6-9\]\[0-9\]\\\..*\\\]" "profile_estimate" } } */