From 3e129b5bc6bc96a0844dcdf75188dc4710028939 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 21 Mar 2018 21:53:16 +0100 Subject: [PATCH] re PR tree-optimization/84960 (ICE in GIMPLE pass: isolate-paths) PR tree-optimization/84960 * tree-cfg.c (remove_bb): Don't move forced labels into bb->prev_bb if it is ENTRY block, move them into single succ of ENTRY in that case. * gcc.c-torture/compile/pr84960.c: New test. From-SVN: r258744 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr84960.c | 17 +++++++++++++++++ gcc/tree-cfg.c | 6 ++++++ 4 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr84960.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2c5ed01e3f4..eeab1f1a3aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-21 Jakub Jelinek + + PR tree-optimization/84960 + * tree-cfg.c (remove_bb): Don't move forced labels into bb->prev_bb + if it is ENTRY block, move them into single succ of ENTRY in that case. + 2018-03-21 Richard Sandiford PR tree-optimization/84811 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 36e16266c00..faf418dd1b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-21 Jakub Jelinek + + PR tree-optimization/84960 + * gcc.c-torture/compile/pr84960.c: New test. + 2018-03-21 Richard Sandiford PR tree-optimization/84811 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr84960.c b/gcc/testsuite/gcc.c-torture/compile/pr84960.c new file mode 100644 index 00000000000..b076f793b09 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr84960.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/84960 */ +/* { dg-do compile { target indirect_jumps } } */ + +void +foo (unsigned int a, float b, void *c) +{ +lab: + if ((b - (a %= 0) < 1U) * -1U) + ; + else + { + unsigned int f = a; + __builtin_unreachable (); + c = &&lab; + } + goto *c; +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index b87e48dade6..9485f73f341 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2301,6 +2301,12 @@ remove_bb (basic_block bb) } new_bb = bb->prev_bb; + /* Don't move any labels into ENTRY block. */ + if (new_bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)) + { + new_bb = single_succ (new_bb); + gcc_assert (new_bb != bb); + } new_gsi = gsi_start_bb (new_bb); gsi_remove (&i, false); gsi_insert_before (&new_gsi, stmt, GSI_NEW_STMT); -- 2.30.2