Commit 7fef86d3 by Jan Hubicka Committed by Martin Liska

Recover GOTO predictor.

2017-07-31  Jan Hubicka <hubicka@ucw.cz>
	    Martin Liska  <mliska@suse.cz>

	* c-typeck.c (c_finish_goto_label): Build gimple predict
	stament.
2017-07-31  Jan Hubicka <hubicka@ucw.cz>
	    Martin Liska  <mliska@suse.cz>

	* predict.def: Remove old comment and adjust probability.
	* gimplify.c (should_warn_for_implicit_fallthrough): Ignore
	PREDICT statements.
2017-07-31  Jan Hubicka <hubicka@ucw.cz>
	    Martin Liska  <mliska@suse.cz>

	* gcc.dg/predict-15.c: New test.
	* gcc.dg/tree-ssa/vrp24.c: Update scanned pattern.
2017-07-31  Jan Hubicka <hubicka@ucw.cz>
	    Martin Liska  <mliska@suse.cz>

	* pt.c (tsubst_copy): Copy PREDICT_EXPR.
	* semantics.c (finish_goto_stmt): Build gimple predict
	stament.
	* constexpr.c (potential_constant_expression_1): Handle
	PREDICT_EXPR.

Co-Authored-By: Martin Liska <mliska@suse.cz>

From-SVN: r250737
parent 2ec580be
2017-07-31 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
* predict.def: Remove old comment and adjust probability.
* gimplify.c (should_warn_for_implicit_fallthrough): Ignore
PREDICT statements.
2017-07-31 Uros Bizjak <ubizjak@gmail.com> 2017-07-31 Uros Bizjak <ubizjak@gmail.com>
PR target/25967 PR target/25967
......
2017-07-31 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
* c-typeck.c (c_finish_goto_label): Build gimple predict
stament.
2017-07-31 Martin Liska <mliska@suse.cz> 2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530 PR sanitize/81530
......
...@@ -9824,6 +9824,7 @@ c_finish_goto_label (location_t loc, tree label) ...@@ -9824,6 +9824,7 @@ c_finish_goto_label (location_t loc, tree label)
return NULL_TREE; return NULL_TREE;
TREE_USED (decl) = 1; TREE_USED (decl) = 1;
{ {
add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
tree t = build1 (GOTO_EXPR, void_type_node, decl); tree t = build1 (GOTO_EXPR, void_type_node, decl);
SET_EXPR_LOCATION (t, loc); SET_EXPR_LOCATION (t, loc);
return add_stmt (t); return add_stmt (t);
......
2017-07-31 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
* pt.c (tsubst_copy): Copy PREDICT_EXPR.
* semantics.c (finish_goto_stmt): Build gimple predict
stament.
* constexpr.c (potential_constant_expression_1): Handle
PREDICT_EXPR.
2017-07-31 Martin Liska <mliska@suse.cz> 2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530 PR sanitize/81530
......
...@@ -5782,6 +5782,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, ...@@ -5782,6 +5782,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
case CLEANUP_STMT: case CLEANUP_STMT:
case EMPTY_CLASS_EXPR: case EMPTY_CLASS_EXPR:
case PREDICT_EXPR:
return false; return false;
case GOTO_EXPR: case GOTO_EXPR:
......
...@@ -15105,6 +15105,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -15105,6 +15105,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
return tsubst_binary_left_fold (t, args, complain, in_decl); return tsubst_binary_left_fold (t, args, complain, in_decl);
case BINARY_RIGHT_FOLD_EXPR: case BINARY_RIGHT_FOLD_EXPR:
return tsubst_binary_right_fold (t, args, complain, in_decl); return tsubst_binary_right_fold (t, args, complain, in_decl);
case PREDICT_EXPR:
return t;
default: default:
/* We shouldn't get here, but keep going if !flag_checking. */ /* We shouldn't get here, but keep going if !flag_checking. */
......
...@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
#include "omp-general.h" #include "omp-general.h"
#include "convert.h" #include "convert.h"
#include "gomp-constants.h" #include "gomp-constants.h"
#include "predict.h"
/* There routines provide a modular interface to perform many parsing /* There routines provide a modular interface to perform many parsing
operations. They may therefore be used during actual parsing, or operations. They may therefore be used during actual parsing, or
...@@ -630,6 +631,7 @@ finish_goto_stmt (tree destination) ...@@ -630,6 +631,7 @@ finish_goto_stmt (tree destination)
check_goto (destination); check_goto (destination);
add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
return add_stmt (build_stmt (input_location, GOTO_EXPR, destination)); return add_stmt (build_stmt (input_location, GOTO_EXPR, destination));
} }
......
...@@ -2037,7 +2037,9 @@ should_warn_for_implicit_fallthrough (gimple_stmt_iterator *gsi_p, tree label) ...@@ -2037,7 +2037,9 @@ should_warn_for_implicit_fallthrough (gimple_stmt_iterator *gsi_p, tree label)
gsi = *gsi_p; gsi = *gsi_p;
/* Skip all immediately following labels. */ /* Skip all immediately following labels. */
while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL) while (!gsi_end_p (gsi)
&& (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL
|| gimple_code (gsi_stmt (gsi)) == GIMPLE_PREDICT))
gsi_next (&gsi); gsi_next (&gsi);
/* { ... something; default:; } */ /* { ... something; default:; } */
......
...@@ -132,9 +132,8 @@ DEF_PREDICTOR (PRED_RECURSIVE_CALL, "recursive call", HITRATE (75), 0) ...@@ -132,9 +132,8 @@ DEF_PREDICTOR (PRED_RECURSIVE_CALL, "recursive call", HITRATE (75), 0)
DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (66), DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (66),
0) 0)
/* Branch containing goto is probably not taken. /* Branch containing goto is probably not taken. */
FIXME: Currently not used. */ DEF_PREDICTOR (PRED_GOTO, "goto", HITRATE (66), 0)
DEF_PREDICTOR (PRED_GOTO, "goto", HITRATE (70), 0)
/* Branch ending with return constant is probably not taken. */ /* Branch ending with return constant is probably not taken. */
DEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (69), 0) DEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (69), 0)
......
2017-07-31 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
* gcc.dg/predict-15.c: New test.
* gcc.dg/tree-ssa/vrp24.c: Update scanned pattern.
2017-07-31 Uros Bizjak <ubizjak@gmail.com> 2017-07-31 Uros Bizjak <ubizjak@gmail.com>
PR target/25967 PR target/25967
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
int main(int argc, char **argv)
{
if (argc == 123)
goto exit;
else
{
return 0;
}
exit:
return 1;
}
/* { dg-final { scan-tree-dump "goto heuristics of edge" "profile_estimate"} } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-profile_estimate-blocks-details" } */ /* { dg-options "-O2 -fdump-tree-profile_estimate" } */
void g(void); int v1, v2;
void h(void);
void f(int x, int y) void f(int x, int y)
{ {
if (x) goto A; if (x) goto A;
...@@ -10,11 +9,11 @@ void f(int x, int y) ...@@ -10,11 +9,11 @@ void f(int x, int y)
return; return;
A: __attribute__((cold)) A: __attribute__((cold))
g(); v1 = x;
return; return;
B: __attribute__((hot)) B: __attribute__((hot))
h(); v2 = y;
return; return;
} }
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */ /* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details -fdump-tree-optimized" } */
struct rtx_def; struct rtx_def;
...@@ -86,10 +86,8 @@ L7: ...@@ -86,10 +86,8 @@ L7:
/* The first n_sets > 0 test can be simplfiied into n_sets == 1 since /* The first n_sets > 0 test can be simplfiied into n_sets == 1 since
n_sets can only have the values [0, 1] as it's the result of a n_sets can only have the values [0, 1] as it's the result of a
boolean operation. boolean operation. */
The second n_sets > 0 test can also be simplified into n_sets == 1 /* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
as the only way to reach the tests is when n_sets <= 1 and the only /* { dg-final { scan-tree-dump-times "if " 4 "optimized" } } */
value which satisfies both conditions is n_sets == 1. */
/* { dg-final { scan-tree-dump-times "Simplified relational" 2 "vrp1" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment