Call compute_outgoing_frequencies at expand 2017-07-17 Tom de Vries PR middle-end/81030 * cfgbuild.c (find_many_sub_basic_blocks): Add and handle update_freq parameter. * cfgbuild.h (find_many_sub_basic_blocks): Add update_freq parameter. * cfgexpand.c (pass_expand::execute): Call find_many_sub_basic_blocks with update_freq == true. * gcc.dg/pr81030.c: New test. --- gcc/cfgbuild.c | 4 ++-- gcc/cfgbuild.h | 3 ++- gcc/cfgexpand.c | 2 +- gcc/testsuite/gcc.dg/pr81030.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c index 56a2cb9..78036fe 100644 --- a/gcc/cfgbuild.c +++ b/gcc/cfgbuild.c @@ -594,7 +594,7 @@ compute_outgoing_frequencies (basic_block b) and create edges. */ void -find_many_sub_basic_blocks (sbitmap blocks) +find_many_sub_basic_blocks (sbitmap blocks, bool update_freq) { basic_block bb, min, max; bool found = false; @@ -677,7 +677,7 @@ find_many_sub_basic_blocks (sbitmap blocks) } else /* If nothing changed, there is no need to create new BBs. */ - if (EDGE_COUNT (bb->succs) == n_succs[bb->index]) + if (!update_freq && EDGE_COUNT (bb->succs) == n_succs[bb->index]) continue; compute_outgoing_frequencies (bb); diff --git a/gcc/cfgbuild.h b/gcc/cfgbuild.h index afda5ac..0c58590 100644 --- a/gcc/cfgbuild.h +++ b/gcc/cfgbuild.h @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see extern bool inside_basic_block_p (const rtx_insn *); extern bool control_flow_insn_p (const rtx_insn *); extern void rtl_make_eh_edge (sbitmap, basic_block, rtx); -extern void find_many_sub_basic_blocks (sbitmap); +extern void find_many_sub_basic_blocks (sbitmap block, + bool update_freq = false); #endif /* GCC_CFGBUILD_H */ diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 3e1d24d..e030a86 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -6464,7 +6464,7 @@ pass_expand::execute (function *fun) auto_sbitmap blocks (last_basic_block_for_fn (fun)); bitmap_ones (blocks); - find_many_sub_basic_blocks (blocks); + find_many_sub_basic_blocks (blocks, true); purge_all_dead_edges (); expand_stack_alignment (); diff --git a/gcc/testsuite/gcc.dg/pr81030.c b/gcc/testsuite/gcc.dg/pr81030.c new file mode 100644 index 0000000..23da6e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81030.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +void __assert_fail (const char *, const char *, unsigned int, const char *); + +int a, b, c, d, e, f, h; +unsigned char g; + +int main () +{ + int i, *j = &b; + if (a) + { + if (h) + { + int **k = &j; + d = 0; + *k = &e; + } + else + for (b = 0; b > -28; b = g) + ; + c || !j ? : __assert_fail ("c || !j", "small.c", 20, "main"); + if (f) + for (i = 0; i < 1; i++) + ; + } + return 0; +}