From: Richard Biener Date: Wed, 23 Jun 2021 07:59:28 +0000 (+0200) Subject: tree-optimization/101173 - fix interchange dependence checking X-Git-Tag: upstream/12.2.0~6861 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ad9d88a3d7170b3d864693c9eb512f89a5096ff;p=platform%2Fupstream%2Fgcc.git tree-optimization/101173 - fix interchange dependence checking This adjusts the loop interchange dependence checking to disallow an outer loop dependence distance of zero. 2021-06-23 Richard Biener PR tree-optimization/101173 * gimple-loop-interchange.cc (tree_loop_interchange::valid_data_dependences): Disallow outer loop dependence distance of zero. * gcc.dg/torture/pr101173.c: New testcase. --- diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc index 80f749b..43045c54 100644 --- a/gcc/gimple-loop-interchange.cc +++ b/gcc/gimple-loop-interchange.cc @@ -1043,8 +1043,8 @@ tree_loop_interchange::valid_data_dependences (unsigned i_idx, unsigned o_idx, continue; /* Be conservative, skip case if either direction at i_idx/o_idx - levels is not '=' or '<'. */ - if (dist_vect[i_idx] < 0 || dist_vect[o_idx] < 0) + levels is not '=' (for the inner loop) or '<'. */ + if (dist_vect[i_idx] < 0 || dist_vect[o_idx] <= 0) return false; } } diff --git a/gcc/testsuite/gcc.dg/torture/pr101173.c b/gcc/testsuite/gcc.dg/torture/pr101173.c new file mode 100644 index 0000000..0c9090d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101173.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-additional-options "-floop-interchange" } */ + +int a[6][9]; +int main() +{ + a[1][3] = 8; + for (int b = 1; b <= 5; b++) + for (int d = 0; d <= 5; d++) +#pragma GCC unroll 0 + for (int c = 0; c <= 5; c++) + a[b][c] = a[b][c + 2] & 216; + for (int e = 0; e < 6; e++) + for (int f = 0; f < 9; f++) + if (a[e][f] != 0) + __builtin_abort (); + return 0; +}