tree-data-ref.c (build_classic_dist_vector): If either loop is outside of the nest...
authorDaniel Berlin <dberlin@dberlin.org>
Wed, 10 Nov 2004 21:32:10 +0000 (21:32 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Wed, 10 Nov 2004 21:32:10 +0000 (21:32 +0000)
2004-11-10  Daniel Berlin  <dberlin@dberlin.org>

* tree-data-ref.c (build_classic_dist_vector): If either loop
is outside of the nest we asked about, the dependence can't
matter.
(build_classic_dir_vector): Ditto.

From-SVN: r90454

gcc/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/20041110-1.c [new file with mode: 0644]
gcc/tree-data-ref.c

index 57c0622dbb5c5cc2f1eb93fa302b9353975e907a..63a487515241c2c0ce5c9de0f89eceef2533d292 100644 (file)
@@ -1,3 +1,10 @@
+2004-11-10  Daniel Berlin  <dberlin@dberlin.org>
+
+       * tree-data-ref.c (build_classic_dist_vector): If either loop
+       is outside of the nest we asked about, the dependence can't
+       matter. 
+       (build_classic_dir_vector): Ditto.
+
 2004-11-10  Zdenek Dvorak  <dvorakz@suse.cz>
 
        * tree-ssa-loop-ivopts.c (get_address_cost): Add address elements in
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20041110-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20041110-1.c
new file mode 100644 (file)
index 0000000..825b2b4
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-linear" } */
+
+/* This testcase was causing an ICE in building distance vectors because
+   we weren't ignoring the fact that one of the induction variables
+   involved in the dependence was outside of the loop.  */
+extern int foo (int, int);
+int
+main (void)
+{
+  int a[50];
+  int b[50];
+  int i, j, k;
+  for (i = 4; i < 30; i++)
+    {
+      for (j = 3; j < 40; j++)
+       {
+         for (k = 9; k < 50; k++)
+           {
+             b[j] = a[i];
+             a[k] = b[i];
+           }
+       }
+    }
+  foo (a[i], b[i]);
+}
index 9a0126c3317b1c9031fdbbe7fff2d9bdfdee1988..3c883465076f59074241c97e12e426012c090374 100644 (file)
@@ -1816,12 +1816,12 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
          struct loop *loop_b = current_loops->parray[loop_nb_b];
          struct loop *loop_first = current_loops->parray[first_loop];
 
-         /* If the loops for both variables are at a lower depth than 
-            the first_loop's depth, then they can't possibly have a
+         /* If the loop for either variable is at a lower depth than 
+            the first_loop's depth, then we can't possibly have a
             dependency at this level of the loop.  */
             
          if (loop_a->depth < loop_first->depth
-             && loop_b->depth < loop_first->depth)
+             || loop_b->depth < loop_first->depth)
            return false;
 
          if (loop_nb_a != loop_nb_b
@@ -1992,11 +1992,12 @@ build_classic_dir_vector (struct data_dependence_relation *ddr,
          struct loop *loop_b = current_loops->parray[loop_nb_b];
          struct loop *loop_first = current_loops->parray[first_loop];
  
-         /* If the loops for both variables are at a lower depth than 
-            the first_loop's depth, then they can't possibly matter */
+         /* If the loop for either variable is at a lower depth than 
+            the first_loop's depth, then we can't possibly have a
+            dependency at this level of the loop.  */
             
          if (loop_a->depth < loop_first->depth
-             && loop_b->depth < loop_first->depth)
+             || loop_b->depth < loop_first->depth)
            return false;
 
          if (loop_nb_a != loop_nb_b