On 2/11/19 10:00 AM, Jan Hubicka wrote: > Aha, yes, fundament of the patch is obvious - the barrier has to go :) > There is same hunk of code in cfgrtl.c:1061, so please just merge it > Note that I am not rtl reviewer. But as author of the code I would say > that the updated patch can go in as obvious. > > Honza
Thank you Honza for review, I'll install it after testing and verifying that it helps to Firefox with PGO. Martin
>From 67aec11ebc560b8ff85bfead32a7caadf8ba7fd4 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Wed, 23 Jan 2019 08:11:15 +0100 Subject: [PATCH] Remove a barrier when EDGE_CROSSING is removed (PR lto/88858). gcc/ChangeLog: 2019-02-12 Martin Liska <mli...@suse.cz> PR lto/88858 * cfgrtl.c (remove_barriers_from_footer): New function. (try_redirect_by_replacing_jump): Use it. (cfg_layout_redirect_edge_and_branch): Likewise. --- gcc/cfgrtl.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 172bdf585d0..56564c2fda7 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -988,6 +988,31 @@ block_label (basic_block block) return as_a <rtx_code_label *> (BB_HEAD (block)); } +/* Remove all barriers from BB_FOOTER of a BB. */ + +static void +remove_barriers_from_footer (basic_block bb) +{ + rtx_insn *insn = BB_FOOTER (bb); + + /* Remove barriers but keep jumptables. */ + while (insn) + { + if (BARRIER_P (insn)) + { + if (PREV_INSN (insn)) + SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); + else + BB_FOOTER (bb) = NEXT_INSN (insn); + if (NEXT_INSN (insn)) + SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); + } + if (LABEL_P (insn)) + return; + insn = NEXT_INSN (insn); + } +} + /* Attempt to perform edge redirection by replacing possibly complex jump instruction by unconditional jump or removing jump completely. This can apply only if all edges now point to the same block. The parameters and @@ -1051,26 +1076,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) /* Selectively unlink whole insn chain. */ if (in_cfglayout) { - rtx_insn *insn = BB_FOOTER (src); - delete_insn_chain (kill_from, BB_END (src), false); - - /* Remove barriers but keep jumptables. */ - while (insn) - { - if (BARRIER_P (insn)) - { - if (PREV_INSN (insn)) - SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); - else - BB_FOOTER (src) = NEXT_INSN (insn); - if (NEXT_INSN (insn)) - SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); - } - if (LABEL_P (insn)) - break; - insn = NEXT_INSN (insn); - } + remove_barriers_from_footer (src); } else delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)), @@ -4396,6 +4403,7 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest) "Removing crossing jump while redirecting edge form %i to %i\n", e->src->index, dest->index); delete_insn (BB_END (src)); + remove_barriers_from_footer (src); e->flags |= EDGE_FALLTHRU; } -- 2.20.1