From: Richard Biener Date: Fri, 25 Jan 2019 08:13:34 +0000 (+0000) Subject: re PR tree-optimization/86865 (Wrong code w/ -O2 -floop-parallelize-all -fstack-reuse... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ad04111c305ea6a20fc99323e0c479ba661c479;p=gcc.git re PR tree-optimization/86865 (Wrong code w/ -O2 -floop-parallelize-all -fstack-reuse=none -fwrapv -fno-tree-ch -fno-tree-dce -fno-tree-dominator-opts -fno-tree-loop-ivcanon) 2019-01-25 Richard Biener PR tree-optimization/86865 * graphite-scop-detection.c (scop_detection::can_represent_loop): Reject non-do-while loops. * gcc.dg/graphite/pr86865.c: New testcase. * gcc.dg/graphite/pr69728.c: XFAIL. * gcc.dg/graphite/scop-21.c: Likewise. From-SVN: r268257 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7156b64dc1d..bdcd4739fa4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-01-25 Richard Biener + + PR tree-optimization/86865 + * graphite-scop-detection.c (scop_detection::can_represent_loop): + Reject non-do-while loops. + 2019-01-24 Peter Bergner * config/rs6000/altivec.md (build_vector_mask_for_load): Use MEM_P. diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 57d3b4806c8..7e8d42cab0d 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -555,8 +555,15 @@ scop_detection::can_represent_loop (loop_p loop, sese_l scop) tree niter; struct tree_niter_desc niter_desc; - return single_exit (loop) - && !(loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP) + /* We can only handle do {} while () style loops correctly. */ + edge exit = single_exit (loop); + if (!exit + || !single_pred_p (loop->latch) + || exit->src != single_pred (loop->latch) + || !empty_block_p (loop->latch)) + return false; + + return !(loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP) && number_of_iterations_exit (loop, single_exit (loop), &niter_desc, false) && niter_desc.control.no_overflow && (niter = number_of_latch_executions (loop)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa88d9d35cb..9803c91e40b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-01-25 Richard Biener + + PR tree-optimization/86865 + * gcc.dg/graphite/pr86865.c: New testcase. + * gcc.dg/graphite/pr69728.c: XFAIL. + * gcc.dg/graphite/scop-21.c: Likewise. + 2019-01-24 Martin Sebor PR c/86125 diff --git a/gcc/testsuite/gcc.dg/graphite/pr69728.c b/gcc/testsuite/gcc.dg/graphite/pr69728.c index e8cd7bec0a1..69e28318aaf 100644 --- a/gcc/testsuite/gcc.dg/graphite/pr69728.c +++ b/gcc/testsuite/gcc.dg/graphite/pr69728.c @@ -24,4 +24,6 @@ fn1 () run into scheduling issues before here, not being able to handle empty domains. */ -/* { dg-final { scan-tree-dump "loop nest optimized" "graphite" } } */ +/* XFAILed by fix for PR86865. */ + +/* { dg-final { scan-tree-dump "loop nest optimized" "graphite" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr86865.c b/gcc/testsuite/gcc.dg/graphite/pr86865.c new file mode 100644 index 00000000000..a6b4208d830 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr86865.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fgraphite-identity -fstack-reuse=none -fwrapv -fno-tree-ch -fno-tree-dce -fno-tree-dominator-opts -fno-tree-loop-ivcanon" } */ + +int xy, tb; + +void +bt (void) +{ + for (xy = 0; xy >= 0; --xy) + { + int yt[8] = { 0 }; + int pz[2] = { 0 }; + int sa[32] = { 0 }; + int us; + + for (us = 0; us < 8; ++us) + yt[us] = 0; + + (void) yt; + (void) pz; + (void) sa; + } + + tb = 1; +} + +int +main (void) +{ + bt (); + if (xy != -1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/scop-21.c b/gcc/testsuite/gcc.dg/graphite/scop-21.c index bd3f811d9d1..304e0792b2b 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-21.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-21.c @@ -30,4 +30,5 @@ int test () return a[20]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ +/* XFAILed by the fix for PR86865. */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite" { xfail *-*-* } } } */