From: Jakub Jelinek Date: Mon, 7 Aug 2017 08:29:21 +0000 (+0200) Subject: re PR middle-end/81698 (expand_case uses wrong edge as default edge) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f5b328d9648e09bd305255d1029b9a22cc598ccb;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4ed00a29bb0..db8204f8e65 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2017-08-07 Jakub Jelinek + + 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 * config/alpha/alpha.c (alpha_reorg): If trap is the last active diff --git a/gcc/stmt.c b/gcc/stmt.c index 05e24f00707..73aa9b2b809 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -945,8 +945,8 @@ conditional_probability (profile_probability target_prob, static void emit_case_dispatch_table (tree index_expr, tree index_type, struct case_node *case_list, rtx default_label, - tree minval, tree maxval, tree range, - basic_block stmt_bb) + edge default_edge, tree minval, tree maxval, + tree range, basic_block stmt_bb) { int i, ncases; struct case_node *n; @@ -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_code_label *table_label = gen_label_rtx (); 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::never (); profile_probability base = get_outgoing_edge_probs (stmt_bb); @@ -1026,9 +1025,8 @@ emit_case_dispatch_table (tree index_expr, tree index_type, through the indirect jump or the direct conditional jump before that. Split the probability of reaching the default label among these two jumps. */ - new_default_prob = conditional_probability (default_prob.apply_scale - (1, 2), - base); + new_default_prob + = conditional_probability (default_prob.apply_scale (1, 2), base); default_prob = default_prob.apply_scale (1, 2); base -= default_prob; } @@ -1147,9 +1145,10 @@ expand_case (gswitch *stmt) do_pending_stack_adjust (); /* Find the default case target label. */ - default_label = jump_target_rtx - (CASE_LABEL (gimple_switch_default_label (stmt))); - edge default_edge = EDGE_SUCC (bb, 0); + tree default_lab = CASE_LABEL (gimple_switch_default_label (stmt)); + default_label = jump_target_rtx (default_lab); + 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; /* Get upper and lower bounds of case values. */ @@ -1245,9 +1244,10 @@ expand_case (gswitch *stmt) { default_label = NULL; remove_edge (default_edge); + default_edge = NULL; } emit_case_dispatch_table (index_expr, index_type, - case_list, default_label, + case_list, default_label, default_edge, minval, maxval, range, bb); } @@ -1340,9 +1340,9 @@ expand_sjlj_dispatch_table (rtx dispatch_index, } emit_case_dispatch_table (index_expr, index_type, - case_list, default_label, + case_list, default_label, NULL, minval, maxval, range, - BLOCK_FOR_INSN (before_case)); + BLOCK_FOR_INSN (before_case)); emit_label (default_label); }