Commit f5b328d9 by Jakub Jelinek Committed by Jakub Jelinek

re PR middle-end/81698 (expand_case uses wrong edge as default edge)

	PR middle-end/81698
	* stmt.c (emit_case_dispatch_table): Add DEFAULT_EDGE argument,
	instead of computing it in the function.  Formatting fix.
	(expand_case): Don't rely on default_edge being the first edge,
	clear it if removing it, pass default_edge to
	emit_case_dispatch_table.
	(expand_sjlj_dispatch_table): Pass NULL as DEFAULT_EDGE, formatting
	fix.

From-SVN: r250909
parent c0e5f294
2017-08-07 Jakub Jelinek <jakub@redhat.com>
PR middle-end/81698
* stmt.c (emit_case_dispatch_table): Add DEFAULT_EDGE argument,
instead of computing it in the function. Formatting fix.
(expand_case): Don't rely on default_edge being the first edge,
clear it if removing it, pass default_edge to
emit_case_dispatch_table.
(expand_sjlj_dispatch_table): Pass NULL as DEFAULT_EDGE, formatting
fix.
2017-08-06 Uros Bizjak <ubizjak@gmail.com> 2017-08-06 Uros Bizjak <ubizjak@gmail.com>
* config/alpha/alpha.c (alpha_reorg): If trap is the last active * config/alpha/alpha.c (alpha_reorg): If trap is the last active
......
...@@ -945,8 +945,8 @@ conditional_probability (profile_probability target_prob, ...@@ -945,8 +945,8 @@ conditional_probability (profile_probability target_prob,
static void static void
emit_case_dispatch_table (tree index_expr, tree index_type, emit_case_dispatch_table (tree index_expr, tree index_type,
struct case_node *case_list, rtx default_label, struct case_node *case_list, rtx default_label,
tree minval, tree maxval, tree range, edge default_edge, tree minval, tree maxval,
basic_block stmt_bb) tree range, basic_block stmt_bb)
{ {
int i, ncases; int i, ncases;
struct case_node *n; struct case_node *n;
...@@ -954,7 +954,6 @@ emit_case_dispatch_table (tree index_expr, tree index_type, ...@@ -954,7 +954,6 @@ emit_case_dispatch_table (tree index_expr, tree index_type,
rtx_insn *fallback_label = label_rtx (case_list->code_label); rtx_insn *fallback_label = label_rtx (case_list->code_label);
rtx_code_label *table_label = gen_label_rtx (); rtx_code_label *table_label = gen_label_rtx ();
bool has_gaps = false; bool has_gaps = false;
edge default_edge = stmt_bb ? EDGE_SUCC (stmt_bb, 0) : NULL;
profile_probability default_prob = default_edge ? default_edge->probability profile_probability default_prob = default_edge ? default_edge->probability
: profile_probability::never (); : profile_probability::never ();
profile_probability base = get_outgoing_edge_probs (stmt_bb); profile_probability base = get_outgoing_edge_probs (stmt_bb);
...@@ -1026,9 +1025,8 @@ emit_case_dispatch_table (tree index_expr, tree index_type, ...@@ -1026,9 +1025,8 @@ emit_case_dispatch_table (tree index_expr, tree index_type,
through the indirect jump or the direct conditional jump through the indirect jump or the direct conditional jump
before that. Split the probability of reaching the before that. Split the probability of reaching the
default label among these two jumps. */ default label among these two jumps. */
new_default_prob = conditional_probability (default_prob.apply_scale new_default_prob
(1, 2), = conditional_probability (default_prob.apply_scale (1, 2), base);
base);
default_prob = default_prob.apply_scale (1, 2); default_prob = default_prob.apply_scale (1, 2);
base -= default_prob; base -= default_prob;
} }
...@@ -1147,9 +1145,10 @@ expand_case (gswitch *stmt) ...@@ -1147,9 +1145,10 @@ expand_case (gswitch *stmt)
do_pending_stack_adjust (); do_pending_stack_adjust ();
/* Find the default case target label. */ /* Find the default case target label. */
default_label = jump_target_rtx tree default_lab = CASE_LABEL (gimple_switch_default_label (stmt));
(CASE_LABEL (gimple_switch_default_label (stmt))); default_label = jump_target_rtx (default_lab);
edge default_edge = EDGE_SUCC (bb, 0); basic_block default_bb = label_to_block_fn (cfun, default_lab);
edge default_edge = find_edge (bb, default_bb);
profile_probability default_prob = default_edge->probability; profile_probability default_prob = default_edge->probability;
/* Get upper and lower bounds of case values. */ /* Get upper and lower bounds of case values. */
...@@ -1245,9 +1244,10 @@ expand_case (gswitch *stmt) ...@@ -1245,9 +1244,10 @@ expand_case (gswitch *stmt)
{ {
default_label = NULL; default_label = NULL;
remove_edge (default_edge); remove_edge (default_edge);
default_edge = NULL;
} }
emit_case_dispatch_table (index_expr, index_type, emit_case_dispatch_table (index_expr, index_type,
case_list, default_label, case_list, default_label, default_edge,
minval, maxval, range, bb); minval, maxval, range, bb);
} }
...@@ -1340,9 +1340,9 @@ expand_sjlj_dispatch_table (rtx dispatch_index, ...@@ -1340,9 +1340,9 @@ expand_sjlj_dispatch_table (rtx dispatch_index,
} }
emit_case_dispatch_table (index_expr, index_type, emit_case_dispatch_table (index_expr, index_type,
case_list, default_label, case_list, default_label, NULL,
minval, maxval, range, minval, maxval, range,
BLOCK_FOR_INSN (before_case)); BLOCK_FOR_INSN (before_case));
emit_label (default_label); emit_label (default_label);
} }
......
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