From 2c790a28841f2a404f1f6e96d07041138583788a Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Tue, 9 May 2006 11:10:15 +0200 Subject: [PATCH] re PR rtl-optimization/27335 (ICE in get_loop_body) PR rtl-optimization/27335 * loop-unroll.c (peel_loops_completely): Use loops->parray to walk the loops. * gcc.dg/pr27335.c: New test. From-SVN: r113648 --- gcc/ChangeLog | 6 ++++++ gcc/loop-unroll.c | 22 +++++++--------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr27335.c | 27 +++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr27335.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d245c389e7c..c1896d9d9b1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-05-09 Zdenek Dvorak + + PR rtl-optimization/27335 + * loop-unroll.c (peel_loops_completely): Use loops->parray to walk the + loops. + 2006-05-08 Chao-ying Fu Richard Sandiford diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index 5c28eaf2f19..156f688651e 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -233,22 +233,15 @@ loop_exit_at_end_p (struct loop *loop) static void peel_loops_completely (struct loops *loops, int flags) { - struct loop *loop, *next; + struct loop *loop; + unsigned i; - loop = loops->tree_root; - while (loop->inner) - loop = loop->inner; - - while (loop != loops->tree_root) + /* Scan the loops, the inner ones first. */ + for (i = loops->num - 1; i > 0; i--) { - if (loop->next) - { - next = loop->next; - while (next->inner) - next = next->inner; - } - else - next = loop->outer; + loop = loops->parray[i]; + if (!loop) + continue; loop->lpt_decision.decision = LPT_NONE; @@ -271,7 +264,6 @@ peel_loops_completely (struct loops *loops, int flags) verify_loop_structure (loops); #endif } - loop = next; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 32927ff4edb..a3f49f7974c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-05-09 Zdenek Dvorak + + PR rtl-optimization/27335 + * gcc.dg/pr27335.c: New test. + 2006-05-06 Richard Sandiford * gcc.target/mips/mips-ps-5.c: New file. diff --git a/gcc/testsuite/gcc.dg/pr27335.c b/gcc/testsuite/gcc.dg/pr27335.c new file mode 100644 index 00000000000..d08db30bdbf --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr27335.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void bar () __attribute__ ((noreturn)); + +inline double +baz (double *x, unsigned int y) +{ + if (y >= 6) + bar (); + return x[y]; +} + +double *a, *b; + +void +foo () +{ + unsigned int r, s, t; + + for (r = 0; r < 2; r++) + for (t = 0; t < 2; t++) + { + for (s = 0; s < 3; s++) + b[r * 2 + t] += baz (a, 3 * s + t); + } +}