From a3357f7dffc52969c120c2ecb9f1c013833ccb9b Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 9 Nov 2010 16:54:05 +0000 Subject: [PATCH] re PR tree-optimization/46355 (ICE: SIGSEGV in create_preheader (cfgloopmanip.c:1336) with -O -fstrict-overflow -ftree-loop-distribution) 2010-11-09 Richard Guenther PR tree-optimization/46355 * tree-loop-distribution.c (tree_loop_distribution): Do not distribute loops without a single exit. * gcc.dg/pr46355.c: New testcase. From-SVN: r166498 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr46355.c | 14 ++++++++++++++ gcc/tree-loop-distribution.c | 7 ++++++- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr46355.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b41bb874659..a828481b1f0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-11-09 Richard Guenther + + PR tree-optimization/46355 + * tree-loop-distribution.c (tree_loop_distribution): Do not + distribute loops without a single exit. + 2010-11-09 Andreas Krebbel PR rtl-optimization/46237 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70493d9c322..1473884c35f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-09 Richard Guenther + + PR tree-optimization/46355 + * gcc.dg/pr46355.c: New testcase. + 2010-11-09 Richard Guenther PR tree-optimization/46177 diff --git a/gcc/testsuite/gcc.dg/pr46355.c b/gcc/testsuite/gcc.dg/pr46355.c new file mode 100644 index 00000000000..e644ec584e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr46355.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-distribution -fstrict-overflow" } */ + +void +foo (int *dest, int i, int u, int v) +{ + int j = i; + while (i) + { + dest[j--] = v; + dest[j--] = u; + } +} + diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 59585cdd761..007c4f383ec 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -1145,7 +1145,12 @@ tree_loop_distribution (void) FOR_EACH_LOOP (li, loop, 0) { - VEC (gimple, heap) *work_list = VEC_alloc (gimple, heap, 3); + VEC (gimple, heap) *work_list = NULL; + + /* If the loop doesn't have a single exit we will fail anyway, + so do that early. */ + if (!single_exit (loop)) + continue; /* If both flag_tree_loop_distribute_patterns and flag_tree_loop_distribution are set, then only -- 2.30.2