From 892d61696c447025d6ccc52eb85a4ab688e122a3 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 30 May 2017 07:49:00 +0000 Subject: [PATCH] re PR tree-optimization/80876 (ICE in verify_loop_structure, at cfgloop.c:1644 (error: loop 1's latch does not have an edge to its header)) 2017-05-30 Richard Biener PR middle-end/80876 * cfgexpand.c (expand_gimple_cond): Fixup preserving loops again. * gcc.dg/torture/pr80876.c: New testcase. From-SVN: r248633 --- gcc/ChangeLog | 5 +++ gcc/cfgexpand.c | 6 ++-- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/torture/pr80876.c | 42 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr80876.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2475e7afbc4..cf7edfd0252 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-05-30 Richard Biener + + PR middle-end/80876 + * cfgexpand.c (expand_gimple_cond): Fixup preserving loops again. + 2017-05-30 Martin Liska * dumpfile.c: Use newly added macro DUMP_FILE_INFO. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 9965310353e..c5b4d70f4a3 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2504,9 +2504,9 @@ expand_gimple_cond (basic_block bb, gcond *stmt) new_bb->count = false_edge->count; new_bb->frequency = EDGE_FREQUENCY (false_edge); add_bb_to_loop (new_bb, dest->loop_father); - if (bb->loop_father->latch == bb - && bb->loop_father->header == dest) - bb->loop_father->latch = new_bb; + if (dest->loop_father->latch == bb + && dest->loop_father->header == dest) + dest->loop_father->latch = new_bb; new_edge = make_edge (new_bb, dest, 0); new_edge->probability = REG_BR_PROB_BASE; new_edge->count = new_bb->count; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1b7ef9779db..682f95fe074 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-30 Richard Biener + + PR middle-end/80876 + * gcc.dg/torture/pr80876.c: New testcase. + 2017-05-29 Nathan Sidwell PR c++/80891 (#5) diff --git a/gcc/testsuite/gcc.dg/torture/pr80876.c b/gcc/testsuite/gcc.dg/torture/pr80876.c new file mode 100644 index 00000000000..35f9f509a64 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr80876.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ + +int sy; + +void +fo (char o5) +{ + char yh = 0; + + if (o5 == 0) + return; + + while (o5 != 0) + if (0) + { + while (yh != 0) + { + o5 = 0; + while (o5 < 2) + { + sy &= yh; + if (sy != 0) + { +km: + sy = yh; + } + } + ++yh; + } + } + else + { + o5 = sy; + goto km; + } +} + +void +on (void) +{ + fo (sy); +} -- 2.30.2