From 7e37fe6f628dc0063a36fbed59a2dcf74e88cce5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 12 May 2015 13:28:33 +0000 Subject: [PATCH] re PR tree-optimization/66101 (internal compiler error: in verify_loop_structure, at cfgloop.c:1662) 2015-05-12 Richard Biener PR tree-optimization/66101 * tree-ssa-dce.c (remove_dead_stmt): Properly mark loops for fixup if we turn a loop exit edge to a fallthru edge. * gcc.dg/torture/pr66101.c: New testcase. From-SVN: r223065 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/torture/pr66101.c | 35 ++++++++++++++++++++++++++ gcc/tree-ssa-dce.c | 7 +++++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr66101.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index adc96c32b00..d3739c2d41d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-05-12 Richard Biener + + PR tree-optimization/66101 + * tree-ssa-dce.c (remove_dead_stmt): Properly mark loops for + fixup if we turn a loop exit edge to a fallthru edge. + 2015-05-12 Richard Biener PR tree-optimization/37021 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9819e2a7731..558a676e96f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-12 Richard Biener + + PR tree-optimization/66101 + * gcc.dg/torture/pr66101.c: New testcase. + 2015-05-12 Richard Biener PR tree-optimization/37021 diff --git a/gcc/testsuite/gcc.dg/torture/pr66101.c b/gcc/testsuite/gcc.dg/torture/pr66101.c new file mode 100644 index 00000000000..f3ef5e55bfd --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr66101.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ + +#include + +jmp_buf env; + +int a, c, d, e; + +int +bar () +{ + int b = *(long *) 7 == 5 ? : 0; + if (a || a > b) + longjmp (env, 0); + return 1; +} + +void +foo () +{ + long f; + setjmp (env); + for (; d; c++) + switch (c) +case 0: + { + f = bar () >> 1; + if (e) + goto L; + if (bar () >> 1) + goto L; + } +L: + ; +} diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index c9cb0e48953..df306142804 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1149,7 +1149,12 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb) if (e != e2) { cfg_altered = true; - remove_edge (e2); + /* If we made a BB unconditionally exit a loop then this + transform alters the set of BBs in the loop. Schedule + a fixup. */ + if (loop_exit_edge_p (bb->loop_father, e)) + loops_state_set (LOOPS_NEED_FIXUP); + remove_edge (e2); } else ei_next (&ei); -- 2.30.2