From 0df7c778ed50095a0c4b266b4beb8b783de832a8 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Mon, 15 Oct 2018 11:35:56 +0000 Subject: [PATCH] re PR tree-optimization/87022 (miscompilation with -ftree-loop-distribution) PR tree-optimization/87022 * tree-loop-distribution.c (pg_add_dependence_edges): Check all bits in dist vector rather than the first one. gcc/testsuite PR tree-optimization/87022 * gcc.dg/tree-ssa/pr87022.c: New test. From-SVN: r265161 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/tree-ssa/pr87022.c | 36 +++++++++++++++++++++++++ gcc/tree-loop-distribution.c | 3 ++- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr87022.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 742f5cf8370..a11504a10c2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-10-15 Bin Cheng + + PR tree-optimization/87022 + * tree-loop-distribution.c (pg_add_dependence_edges): Check all + bits in dist vector rather than the first one. + 2018-10-15 Richard Biener PR middle-end/87610 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e189162c654..df20c3c93dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-15 Bin Cheng + + PR tree-optimization/87022 + * gcc.dg/tree-ssa/pr87022.c: New test. + 2018-10-15 Richard Biener PR middle-end/87610 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr87022.c b/gcc/testsuite/gcc.dg/tree-ssa/pr87022.c new file mode 100644 index 00000000000..b882c35cfbd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr87022.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +void abort(); +char a[7]; +char b[10][7]; +char r[10][7] = { {0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0}, + {0,0,1,1,1,1,1}, + {0,0,1,1,1,1,1}, + {0,0,1,1,1,1,1}}; +short c; +int d, e, f, g; +int main() { + for (; d <= 4; d++) { + e = 0; + for (; e <= 6; e++) { + if (a[c]) + b[e + 3][d + 2] = 1; + a[0] = 5; + b[e][d + 2] = 0; + } + } + for (; f < 10; f++) { + g = 0; + for (; g < 7; g++) + if (b[f][g] != r[f][g]) + abort (); + } + return 0; +} diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index d8db03b545b..1e8a9f0991b 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -1921,7 +1921,8 @@ pg_add_dependence_edges (struct graph *rdg, int dir, if (DDR_NUM_DIST_VECTS (ddr) != 1) this_dir = 2; /* If the overlap is exact preserve stmt order. */ - else if (lambda_vector_zerop (DDR_DIST_VECT (ddr, 0), 1)) + else if (lambda_vector_zerop (DDR_DIST_VECT (ddr, 0), + DDR_NB_LOOPS (ddr))) ; /* Else as the distance vector is lexicographic positive swap the dependence direction. */ -- 2.30.2