aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gimple-loop-interchange.cc7
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c22
2 files changed, 27 insertions, 2 deletions
diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index 43045c54..43ef112 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -1043,8 +1043,11 @@ 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 '=' (for the inner loop) or '<'. */
- if (dist_vect[i_idx] < 0 || dist_vect[o_idx] <= 0)
+ levels is not '=' or '<'. */
+ if (dist_vect[i_idx] < 0
+ || (DDR_REVERSED_P (ddr) && dist_vect[i_idx] > 0)
+ || dist_vect[o_idx] < 0
+ || (DDR_REVERSED_P (ddr) && dist_vect[o_idx] > 0))
return false;
}
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c
new file mode 100644
index 0000000..781555e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c
@@ -0,0 +1,22 @@
+/* PR/101280 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-linterchange-details" } */
+
+void dummy (double *, double *);
+#define LEN_2D 32
+double aa[LEN_2D][LEN_2D], bb[LEN_2D][LEN_2D];
+double s231(int iterations)
+{
+// loop interchange
+// loop with data dependency
+ for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) {
+ for (int i = 0; i < LEN_2D; ++i) {
+ for (int j = 1; j < LEN_2D; j++) {
+ aa[j][i] = aa[j - 1][i] + bb[j][i];
+ }
+ }
+ dummy(aa[0],bb[0]);
+ }
+}
+
+/* { dg-final { scan-tree-dump "loops interchanged" "linterchange" } } */