diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eaf3bafa486..923a9613e86 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-09-17 Alexander Monakov + + * 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 * common.opt (fipa-sra): New switch. diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index ad64b8c3499..ccf539eb0dc 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -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; + tree low, high; - /* 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); - - 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); + } } } diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index d94cb78d24c..3572d1794de 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2009-09-17 Alexander Monakov + + * testsuite/libgomp.graphite/bounds.c: New test. + 2009-09-11 Ralf Wildenhues * 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 index 00000000000..bd36c0f8a22 --- /dev/null +++ b/libgomp/testsuite/libgomp.graphite/bounds.c @@ -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" } } */