From: Richard Biener Date: Wed, 8 Feb 2017 08:30:48 +0000 (+0000) Subject: re PR tree-optimization/71824 (ICE when compiling libiberty with Graphite loop optimi... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d798497efc24b3787683cd31ead1863fa7a461f5;p=gcc.git re PR tree-optimization/71824 (ICE when compiling libiberty with Graphite loop optimizations) 2017-02-08 Richard Biener PR tree-optimization/71824 * graphite-scop-detection.c (scop_detection::build_scop_breadth): Check all loops contained in the merged region. * gcc.dg/graphite/pr71824-2.c: New testcase. From-SVN: r245270 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 527143ac944..1b518e68aed 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-02-08 Richard Biener + + PR tree-optimization/71824 + * graphite-scop-detection.c (scop_detection::build_scop_breadth): + Check all loops contained in the merged region. + 2017-02-07 Andrew Pinski * config/aarch64/aarch64.md (popcount2): New pattern. diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 2f9641235e2..ee1f705b490 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -905,9 +905,19 @@ scop_detection::build_scop_breadth (sese_l s1, loop_p loop) sese_l combined = merge_sese (s1, s2); - if (combined - && loop_is_valid_in_scop (loop, combined) - && loop_is_valid_in_scop (loop->next, combined)) + /* Combining adjacent loops may add unrelated loops into the + region so we have to check all sub-loops of the outer loop + that are in the combined region. */ + if (combined) + for (l = loop_outer (loop)->inner; l; l = l->next) + if (bb_in_sese_p (l->header, combined) + && ! loop_is_valid_in_scop (l, combined)) + { + combined = invalid_sese; + break; + } + + if (combined) s1 = combined; else add_scop (s2); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 81b25807dd0..260a3a57b60 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-08 Richard Biener + + PR tree-optimization/71824 + * gcc.dg/graphite/pr71824-2.c: New testcase. + 2017-02-07 Andrew Pinski * gcc.target/aarch64/popcount.c : New Testcase. diff --git a/gcc/testsuite/gcc.dg/graphite/pr71824-2.c b/gcc/testsuite/gcc.dg/graphite/pr71824-2.c new file mode 100644 index 00000000000..18176568d4a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr71824-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-nest-optimize" } */ + +typedef struct { float x1; } bx; +typedef struct { + int w; + short o; +} T2P; +T2P a; +int b; +void fn2(); +void fn3(bx*,short); +void fn1() { + unsigned i = 0; + int c; + bx *d; + bx **h; + if (b == 0) { + fn2(); + return; + } + for (; c; c++) + for (; i < 100; i++) { + d = h[i]; + d->x1 = a.w; + } + for (; i < 100; i++) { + d = h[i]; + d->x1 = a.w; + } + if (a.o) + for (; b;) + fn3(d, a.o); +}