From 3551257c5d24d5193edbdbc4604c1d995d50902b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 30 Apr 2013 15:03:58 +0000 Subject: [PATCH] =?utf8?q?re=20PR=20tree-optimization/57122=20(ICE=20in=20?= =?utf8?q?verify=5Floop=5Fstructure,=20at=20cfgloop.c:1647=20(loop=20n?= =?utf8?q?=E2=80=99s=20latch=20does=20not=20have=20an=20edge=20to=20its=20?= =?utf8?q?header=20!))?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2013-04-30 Richard Biener PR middle-end/57122 * cfghooks.c (split_edge): Properly check for the loop latch edge. * gcc.dg/torture/pr57122.c: New testcase. From-SVN: r198456 --- gcc/ChangeLog | 6 ++++++ gcc/cfghooks.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr57122.c | 27 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr57122.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb86d6e8e30..02b77f9c612 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-04-30 Richard Biener + + PR middle-end/57122 + * cfghooks.c (split_edge): Properly check for the loop + latch edge. + 2013-04-30 Richard Biener PR middle-end/57107 diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c index f583b2fcc39..22b962b52b1 100644 --- a/gcc/cfghooks.c +++ b/gcc/cfghooks.c @@ -662,7 +662,9 @@ split_edge (edge e) loop = find_common_loop (src->loop_father, dest->loop_father); add_bb_to_loop (ret, loop); - if (loop->latch == src) + /* If we split the latch edge of loop adjust the latch block. */ + if (loop->latch == src + && loop->header == dest) loop->latch = ret; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0d5705a60ed..ae111b265c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-04-30 Richard Biener + + PR middle-end/57122 + * gcc.dg/torture/pr57122.c: New testcase. + 2013-04-30 Richard Biener PR middle-end/57107 diff --git a/gcc/testsuite/gcc.dg/torture/pr57122.c b/gcc/testsuite/gcc.dg/torture/pr57122.c new file mode 100644 index 00000000000..f1b99c86209 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57122.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +unsigned a; +int b, c; + +void f(void) +{ + if(a) + { + for(a = 0; a < 2; a++) + a /= 7; + + for(;; a++) + { + if(a) + lbl1: + b++; + + if(c) + goto lbl1; +lbl2: + ; + } + } + + goto lbl2; +} -- 2.30.2