OSDN Git Service

2009-09-17 Alexander Monakov <amonakov@ispras.ru>
authoramonakov <amonakov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Sep 2009 13:33:37 +0000 (13:33 +0000)
committeramonakov <amonakov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Sep 2009 13:33:37 +0000 (13:33 +0000)
gcc:
* graphite-sese-to-poly.c (pdr_add_data_dimensions): Add bounds only
for ARRAY_REFs.  Use array_ref_{low,up}_bound to determine bounds.

libgomp:
* testsuite/libgomp.graphite/bounds.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151802 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/graphite-sese-to-poly.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.graphite/bounds.c [new file with mode: 0644]

index eaf3baf..923a961 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-17  Alexander Monakov  <amonakov@ispras.ru>
+
+       * graphite-sese-to-poly.c (pdr_add_data_dimensions): Add bounds only
+       for ARRAY_REFs.  Use array_ref_{low,up}_bound to determine bounds.
+
 2009-09-17  Martin Jambor  <mjambor@suse.cz>
 
        * common.opt (fipa-sra): New switch.
index ad64b8c..ccf539e 100644 (file)
@@ -1654,45 +1654,26 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
 {
   tree ref = DR_REF (dr);
   int i, nb_subscripts = DR_NUM_DIMENSIONS (dr);
-  tree array_size;
-  HOST_WIDE_INT elt_size;
 
-  array_size = TYPE_SIZE (TREE_TYPE (ref));
-  if (array_size == NULL_TREE
-      || TREE_CODE (array_size) != INTEGER_CST)
-    return;
-
-  elt_size = int_cst_value (array_size);
-
-  for (i = nb_subscripts - 1; i >= 0; i--)
+  for (i = nb_subscripts - 1; i >= 0; i--, ref = TREE_OPERAND (ref, 0))
     {
       ppl_Linear_Expression_t expr;
       ppl_Constraint_t cstr;
       ppl_dimension_type subscript = dom_nb_dims + 1 + i;
-      int size;
-
-      /* 0 <= subscript */
-      ppl_new_Linear_Expression_with_dimension (&expr, accessp_nb_dims);
-      ppl_set_coef (expr, subscript, 1);
-      ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-      ppl_Polyhedron_add_constraint (accesses, cstr);
-      ppl_delete_Linear_Expression (expr);
-      ppl_delete_Constraint (cstr);
+      tree low, high;
 
-      ref = TREE_OPERAND (ref, 0);
-      array_size = TYPE_SIZE (TREE_TYPE (ref));
-      if (array_size == NULL_TREE
-         || TREE_CODE (array_size) != INTEGER_CST)
+      if (TREE_CODE (ref) != ARRAY_REF)
        break;
 
-      /* subscript <= array_size */
-      size = elt_size ? int_cst_value (array_size) / elt_size : 0;
-      if (size)
+      low = array_ref_low_bound (ref);
+
+      /* subscript - low >= 0 */
+      if (host_integerp (low, 0))
        {
          ppl_new_Linear_Expression_with_dimension (&expr, accessp_nb_dims);
-         ppl_set_coef (expr, subscript, -1);
+         ppl_set_coef (expr, subscript, 1);
 
-         ppl_set_inhomogeneous (expr, size);
+         ppl_set_inhomogeneous (expr, -int_cst_value (low));
 
          ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
          ppl_Polyhedron_add_constraint (accesses, cstr);
@@ -1700,7 +1681,23 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
          ppl_delete_Constraint (cstr);
        }
 
-      elt_size = int_cst_value (array_size);
+      high = array_ref_up_bound (ref);
+
+      /* high - subscript >= 0
+        XXX: 1-element arrays at end of structures may extend over their
+        declared size.  */
+      if (high && host_integerp (high, 0))
+       {
+         ppl_new_Linear_Expression_with_dimension (&expr, accessp_nb_dims);
+         ppl_set_coef (expr, subscript, -1);
+
+         ppl_set_inhomogeneous (expr, int_cst_value (high));
+
+         ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
+         ppl_Polyhedron_add_constraint (accesses, cstr);
+         ppl_delete_Linear_Expression (expr);
+         ppl_delete_Constraint (cstr);
+       }
     }
 }
 
index d94cb78..3572d17 100644 (file)
@@ -1,3 +1,7 @@
+2009-09-17  Alexander Monakov  <amonakov@ispras.ru>
+
+       * testsuite/libgomp.graphite/bounds.c: New test.
+
 2009-09-11  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * Makefile.am (libgomp_la_LINK): New.
diff --git a/libgomp/testsuite/libgomp.graphite/bounds.c b/libgomp/testsuite/libgomp.graphite/bounds.c
new file mode 100644 (file)
index 0000000..bd36c0f
--- /dev/null
@@ -0,0 +1,13 @@
+int foo(int *a, int n)
+{
+  int i;
+  for (i = 2; i < n; i++)
+    a[i] += a[i+1];
+}
+
+/* Check that Graphite dependency checking notes the dependency.  */
+/* { dg-do compile } */
+/* { dg-final { scan-tree-dump-times "0 loops carried no dependency" 1 "graphite" } } */
+/* { dg-final { cleanup-tree-dump "graphite" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */