This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix PR42637


Hi,

The attached patches are fixing the PR42637, and add for all the loop
blocking and interchange tests in the Graphite C testsuite a runtime
check.  Patches have been bootstrapped and regtested on amd64-linux,
and also tested on the SPEC2006 benchmarks.  Committed to trunk.

Sebastian
>From db9290476a773d5fee9c4f17172f2ea8049c83de Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Jan 2010 06:22:13 +0000
Subject: [PATCH 01/13] Cleanup build relation.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (build_pairwise_constraint): Renamed
	ppl_build_relation.  Moved...
	(dr_equality_constraints): Use ppl_build_relation.
	(build_pairwise_scheduling_equality): Same.
	(build_pairwise_scheduling_inequality): Same.
	* graphite-ppl.c (ppl_build_relation): ...here.
	* graphite-ppl.h (ppl_build_relation): Declared.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156058 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite     |   10 +++++
 gcc/graphite-dependences.c |   92 +++++++-------------------------------------
 gcc/graphite-ppl.c         |   40 +++++++++++++++++++
 gcc/graphite-ppl.h         |    2 +
 4 files changed, 66 insertions(+), 78 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index c2bb01e..fbfe742 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,13 @@
+2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* graphite-dependences.c (build_pairwise_constraint): Renamed
+	ppl_build_relation.  Moved...
+	(dr_equality_constraints): Use ppl_build_relation.
+	(build_pairwise_scheduling_equality): Same.
+	(build_pairwise_scheduling_inequality): Same.
+	* graphite-ppl.c (ppl_build_relation): ...here.
+	* graphite-ppl.h (ppl_build_relation): Declared.
+
 2010-01-14  Sebastian Pop  <sebastian.pop@amd.com>
 
 	PR middle-end/42681
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index b77de08..d2c67f3 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -190,93 +190,29 @@ map_dr_into_dep_poly (graphite_dim_t dim,
   return res;
 }
 
-/* Builds a constraints of the form "POS1 - POS2 CSTR_TYPE C" */
-
-static ppl_Constraint_t
-build_pairwise_constraint (graphite_dim_t dim,
-		           graphite_dim_t pos1, graphite_dim_t pos2,
-			   int c, enum ppl_enum_Constraint_Type cstr_type)
-{
-  ppl_Linear_Expression_t expr;
-  ppl_Constraint_t cstr;
-  ppl_Coefficient_t coef;
-  Value v, v_op, v_c;
-
-  value_init (v);
-  value_init (v_op);
-  value_init (v_c);
-
-  value_set_si (v, 1);
-  value_set_si (v_op, -1);
-  value_set_si (v_c, c);
-
-  ppl_new_Coefficient (&coef);
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-  ppl_assign_Coefficient_from_mpz_t (coef, v);
-  ppl_Linear_Expression_add_to_coefficient (expr, pos1, coef);
-  ppl_assign_Coefficient_from_mpz_t (coef, v_op);
-  ppl_Linear_Expression_add_to_coefficient (expr, pos2, coef);
-  ppl_assign_Coefficient_from_mpz_t (coef, v_c);
-  ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
-
-  ppl_new_Constraint (&cstr, expr, cstr_type);
-
-  ppl_delete_Linear_Expression (expr);
-  ppl_delete_Coefficient (coef);
-  value_clear (v);
-  value_clear (v_op);
-  value_clear (v_c);
-
-  return cstr;
-}
-
 /* Builds subscript equality constraints.  */
 
 static ppl_Pointset_Powerset_C_Polyhedron_t
 dr_equality_constraints (graphite_dim_t dim,
 		         graphite_dim_t pos, graphite_dim_t nb_subscripts)
 {
-  ppl_Polyhedron_t subscript_equalities;
+  ppl_Polyhedron_t eqs;
   ppl_Pointset_Powerset_C_Polyhedron_t res;
-  Value v, v_op;
   graphite_dim_t i;
 
-  value_init (v);
-  value_init (v_op);
-  value_set_si (v, 1);
-  value_set_si (v_op, -1);
+  ppl_new_C_Polyhedron_from_space_dimension (&eqs, dim, 0);
 
-  ppl_new_C_Polyhedron_from_space_dimension (&subscript_equalities, dim, 0);
   for (i = 0; i < nb_subscripts; i++)
     {
-      ppl_Linear_Expression_t expr;
-      ppl_Constraint_t cstr;
-      ppl_Coefficient_t coef;
-
-      ppl_new_Coefficient (&coef);
-      ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-      ppl_assign_Coefficient_from_mpz_t (coef, v);
-      ppl_Linear_Expression_add_to_coefficient (expr, pos + i, coef);
-      ppl_assign_Coefficient_from_mpz_t (coef, v_op);
-      ppl_Linear_Expression_add_to_coefficient (expr, pos + i + nb_subscripts,
-						coef);
-
-      ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_Polyhedron_add_constraint (subscript_equalities, cstr);
-
-      ppl_delete_Linear_Expression (expr);
+      ppl_Constraint_t cstr
+	= ppl_build_relation (dim, pos + i, pos + i + nb_subscripts,
+			      0, PPL_CONSTRAINT_TYPE_EQUAL);
+      ppl_Polyhedron_add_constraint (eqs, cstr);
       ppl_delete_Constraint (cstr);
-      ppl_delete_Coefficient (coef);
     }
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-    (&res, subscript_equalities);
-  value_clear (v);
-  value_clear (v_op);
-  ppl_delete_Polyhedron (subscript_equalities);
-
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&res, eqs);
+  ppl_delete_Polyhedron (eqs);
   return res;
 }
 
@@ -292,8 +228,8 @@ build_pairwise_scheduling_equality (graphite_dim_t dim,
 
   ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
 
-  cstr = build_pairwise_constraint (dim, pos, pos + offset, 0,
-				    PPL_CONSTRAINT_TYPE_EQUAL);
+  cstr = ppl_build_relation (dim, pos, pos + offset, 0,
+			     PPL_CONSTRAINT_TYPE_EQUAL);
   ppl_Polyhedron_add_constraint (equalities, cstr);
   ppl_delete_Constraint (cstr);
 
@@ -317,11 +253,11 @@ build_pairwise_scheduling_inequality (graphite_dim_t dim,
   ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
 
   if (direction)
-    cstr = build_pairwise_constraint (dim, pos, pos + offset, -1,
-				      PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
+    cstr = ppl_build_relation (dim, pos, pos + offset, -1,
+			       PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
   else
-    cstr = build_pairwise_constraint (dim, pos, pos + offset, 1,
-				      PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
+    cstr = ppl_build_relation (dim, pos, pos + offset, 1,
+			       PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
 
   ppl_Polyhedron_add_constraint (equalities, cstr);
   ppl_delete_Constraint (cstr);
diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c
index b47e24a..38faebd 100644
--- a/gcc/graphite-ppl.c
+++ b/gcc/graphite-ppl.c
@@ -700,5 +700,45 @@ ppl_min_for_le_polyhedron (ppl_Polyhedron_t pol,
   ppl_delete_Coefficient (denom);
 }
 
+/* Builds a constraint in dimension DIM relating dimensions POS1 to
+   POS2 as "POS1 - POS2 CSTR_TYPE C" */
+
+ppl_Constraint_t
+ppl_build_relation (int dim, int pos1, int pos2, int c,
+		    enum ppl_enum_Constraint_Type cstr_type)
+{
+  ppl_Linear_Expression_t expr;
+  ppl_Constraint_t cstr;
+  ppl_Coefficient_t coef;
+  Value v, v_op, v_c;
+
+  value_init (v);
+  value_init (v_op);
+  value_init (v_c);
+
+  value_set_si (v, 1);
+  value_set_si (v_op, -1);
+  value_set_si (v_c, c);
+
+  ppl_new_Coefficient (&coef);
+  ppl_new_Linear_Expression_with_dimension (&expr, dim);
+
+  ppl_assign_Coefficient_from_mpz_t (coef, v);
+  ppl_Linear_Expression_add_to_coefficient (expr, pos1, coef);
+  ppl_assign_Coefficient_from_mpz_t (coef, v_op);
+  ppl_Linear_Expression_add_to_coefficient (expr, pos2, coef);
+  ppl_assign_Coefficient_from_mpz_t (coef, v_c);
+  ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
+
+  ppl_new_Constraint (&cstr, expr, cstr_type);
+
+  ppl_delete_Linear_Expression (expr);
+  ppl_delete_Coefficient (coef);
+  value_clear (v);
+  value_clear (v_op);
+  value_clear (v_c);
+
+  return cstr;
+}
 
 #endif
diff --git a/gcc/graphite-ppl.h b/gcc/graphite-ppl.h
index f7dc2b3..488ad6f 100644
--- a/gcc/graphite-ppl.h
+++ b/gcc/graphite-ppl.h
@@ -50,6 +50,8 @@ void ppl_max_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t,
                               ppl_Linear_Expression_t, Value);
 void ppl_min_for_le_polyhedron (ppl_Polyhedron_t, ppl_Linear_Expression_t,
 				Value);
+ppl_Constraint_t ppl_build_relation (int, int, int, int,
+				     enum ppl_enum_Constraint_Type);
 
 /* Assigns to RES the value of the INTEGER_CST T.  */
 
-- 
1.6.3.3

>From 875f6a2db47ab6ad36156ef227a5acb68c98fd85 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Jan 2010 06:22:18 +0000
Subject: [PATCH 02/13] Factor uses of build_pairwise_scheduling.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (build_pairwise_scheduling_equality): Removed.
	(build_pairwise_scheduling_inequality): Renamed build_pairwise_scheduling.
	(lexicographically_gt_p): Change type of direction to int.
	(build_lexicographically_gt_constraint): Same.
	(dependence_polyhedron_1): Same.
	(dependence_polyhedron): Same.
	(pddr_original_scattering): Use integers for direction.
	(pddr_transformed_scattering): Same.
	(graphite_legal_transform_dr): Same.
	(graphite_carried_dependence_level_k): Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156059 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite     |   13 +++++++
 gcc/graphite-dependences.c |   78 ++++++++++++++++++++-----------------------
 2 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index fbfe742..a160dde 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,18 @@
 2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-dependences.c (build_pairwise_scheduling_equality): Removed.
+	(build_pairwise_scheduling_inequality): Renamed build_pairwise_scheduling.
+	(lexicographically_gt_p): Change type of direction to int.
+	(build_lexicographically_gt_constraint): Same.
+	(dependence_polyhedron_1): Same.
+	(dependence_polyhedron): Same.
+	(pddr_original_scattering): Use integers for direction.
+	(pddr_transformed_scattering): Same.
+	(graphite_legal_transform_dr): Same.
+	(graphite_carried_dependence_level_k): Same.
+
+2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (build_pairwise_constraint): Renamed
 	ppl_build_relation.  Moved...
 	(dr_equality_constraints): Use ppl_build_relation.
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index d2c67f3..bc9d270 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -216,11 +216,16 @@ dr_equality_constraints (graphite_dim_t dim,
   return res;
 }
 
-/* Builds scheduling equality constraints.  */
+/* Builds scheduling inequality constraints: when DIRECTION is
+   1 builds a GE constraint,
+   0 builds an EQ constraint,
+   -1 builds a LE constraint.  */
 
 static ppl_Pointset_Powerset_C_Polyhedron_t
-build_pairwise_scheduling_equality (graphite_dim_t dim,
-		                    graphite_dim_t pos, graphite_dim_t offset)
+build_pairwise_scheduling (graphite_dim_t dim,
+			   graphite_dim_t pos,
+			   graphite_dim_t offset,
+			   int direction)
 {
   ppl_Pointset_Powerset_C_Polyhedron_t res;
   ppl_Polyhedron_t equalities;
@@ -228,36 +233,26 @@ build_pairwise_scheduling_equality (graphite_dim_t dim,
 
   ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
 
-  cstr = ppl_build_relation (dim, pos, pos + offset, 0,
-			     PPL_CONSTRAINT_TYPE_EQUAL);
-  ppl_Polyhedron_add_constraint (equalities, cstr);
-  ppl_delete_Constraint (cstr);
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&res, equalities);
-  ppl_delete_Polyhedron (equalities);
-  return res;
-}
-
-/* Builds scheduling inequality constraints.  */
+  switch (direction)
+    {
+    case -1:
+      cstr = ppl_build_relation (dim, pos, pos + offset, 1,
+				 PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
+      break;
 
-static ppl_Pointset_Powerset_C_Polyhedron_t
-build_pairwise_scheduling_inequality (graphite_dim_t dim,
-				      graphite_dim_t pos,
-				      graphite_dim_t offset,
-				      bool direction)
-{
-  ppl_Pointset_Powerset_C_Polyhedron_t res;
-  ppl_Polyhedron_t equalities;
-  ppl_Constraint_t cstr;
+    case 0:
+      cstr = ppl_build_relation (dim, pos, pos + offset, 0,
+				 PPL_CONSTRAINT_TYPE_EQUAL);
+      break;
 
-  ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
+    case 1:
+      cstr = ppl_build_relation (dim, pos, pos + offset, -1,
+				 PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
+      break;
 
-  if (direction)
-    cstr = ppl_build_relation (dim, pos, pos + offset, -1,
-			       PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-  else
-    cstr = ppl_build_relation (dim, pos, pos + offset, 1,
-			       PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
+    default:
+      gcc_unreachable ();
+    }
 
   ppl_Polyhedron_add_constraint (equalities, cstr);
   ppl_delete_Constraint (cstr);
@@ -274,13 +269,12 @@ static bool
 lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res,
 			graphite_dim_t dim,
 			graphite_dim_t offset,
-			bool direction, graphite_dim_t i)
+			int direction, graphite_dim_t i)
 {
   ppl_Pointset_Powerset_C_Polyhedron_t ineq;
   bool empty_p;
 
-  ineq = build_pairwise_scheduling_inequality (dim, i, offset,
-					       direction);
+  ineq = build_pairwise_scheduling (dim, i, offset, direction);
   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (ineq, res);
   empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (ineq);
   if (!empty_p)
@@ -298,7 +292,7 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
 				       graphite_dim_t dim,
 				       graphite_dim_t tdim1,
 				       graphite_dim_t offset,
-				       bool direction)
+				       int direction)
 {
   graphite_dim_t i;
 
@@ -309,7 +303,7 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
     {
       ppl_Pointset_Powerset_C_Polyhedron_t sceq;
 
-      sceq = build_pairwise_scheduling_equality (dim, i, offset);
+      sceq = build_pairwise_scheduling (dim, i, offset, 0);
       ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, sceq);
       ppl_delete_Pointset_Powerset_C_Polyhedron (sceq);
 
@@ -341,7 +335,7 @@ dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
 		         ppl_Pointset_Powerset_C_Polyhedron_t d2,
 		         poly_dr_p pdr1, poly_dr_p pdr2,
 	                 ppl_Polyhedron_t s1, ppl_Polyhedron_t s2,
-		         bool direction,
+		         int direction,
 		         bool original_scattering_p)
 {
   scop_p scop = PBB_SCOP (pbb1);
@@ -419,7 +413,7 @@ dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
 		       ppl_Pointset_Powerset_C_Polyhedron_t d2,
 		       poly_dr_p pdr1, poly_dr_p pdr2,
 	               ppl_Polyhedron_t s1, ppl_Polyhedron_t s2,
-		       bool direction,
+		       int direction,
 		       bool original_scattering_p)
 {
   PTR *x = NULL;
@@ -470,7 +464,7 @@ pddr_original_scattering (poly_bb_p pbb1, poly_bb_p pbb2,
     return NULL;
 
   pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
-				true, true);
+				1, true);
   if (pddr_is_empty (pddr))
     return NULL;
 
@@ -497,7 +491,7 @@ pddr_transformed_scattering (poly_bb_p pbb1, poly_bb_p pbb2,
     return NULL;
 
   pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, st1, st2,
-				true, false);
+				1, false);
   if (pddr_is_empty (pddr))
     return NULL;
 
@@ -585,7 +579,7 @@ graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (temp, po);
 
   pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, st1, st2,
-				false, false);
+				-1, false);
   pt = PDDR_DDP (pddr);
 
   /* Extend PO and PT to have the same dimensions.  */
@@ -755,14 +749,14 @@ graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
     return false;
 
   pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
-				true, false);
+				1, false);
 
   if (pddr_is_empty (pddr))
     return false;
 
   po = PDDR_DDP (pddr);
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &dim);
-  eqpp = build_pairwise_scheduling_inequality (dim, level, tdim1 + ddim1, 1);
+  eqpp = build_pairwise_scheduling (dim, level, tdim1 + ddim1, 1);
 
   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (eqpp, po);
   empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (eqpp);
-- 
1.6.3.3

>From dacad293bfdcc37a284e4265c2cc0c29c1e806f7 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Jan 2010 06:22:22 +0000
Subject: [PATCH 03/13] Add missing function comments.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (lexicographically_gt_p): Add comments.
	(build_lexicographically_gt_constraint): Same.
	(dependence_polyhedron_1): Same.
	(dependence_polyhedron): Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156060 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite     |    7 +++++
 gcc/graphite-dependences.c |   59 +++++++++++++++++++++++++++++++++----------
 2 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index a160dde..8d26291 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,12 @@
 2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-dependences.c (lexicographically_gt_p): Add comments.
+	(build_lexicographically_gt_constraint): Same.
+	(dependence_polyhedron_1): Same.
+	(dependence_polyhedron): Same.
+
+2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (build_pairwise_scheduling_equality): Removed.
 	(build_pairwise_scheduling_inequality): Renamed build_pairwise_scheduling.
 	(lexicographically_gt_p): Change type of direction to int.
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index bc9d270..e096cba 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -262,8 +262,13 @@ build_pairwise_scheduling (graphite_dim_t dim,
   return res;
 }
 
-/* Returns true when adding the lexicographical constraints at level I
-   to the RES dependence polyhedron returns an empty polyhedron.  */
+/* Returns true when adding to the RES dependence polyhedron the
+   lexicographical constraint: "DIM compared to DIM + OFFSET" returns
+   an empty polyhedron.  The comparison depends on DIRECTION as: if
+   DIRECTION is equal to -1, the first dimension DIM to be compared
+   comes before the second dimension DIM + OFFSET, equal to 0 when DIM
+   and DIM + OFFSET are equal, and DIRECTION is set to 1 when DIM
+   comes after DIM + OFFSET.  */
 
 static bool
 lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res,
@@ -284,13 +289,21 @@ lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res,
   return !empty_p;
 }
 
-/* Build the precedence constraints for the lexicographical comparison
-   of time vectors RES following the lexicographical order.  */
+/* Add to a non empty polyhedron RES the precedence constraints for
+   the lexicographical comparison of time vectors in RES following the
+   lexicographical order.  DIM is the dimension of the polyhedron RES.
+   TDIM is the number of loops common to the two statements that are
+   compared lexicographically, i.e. the number of loops containing
+   both statements.  OFFSET is the number of dimensions needed to
+   represent the first statement, i.e. dimT1 + dimI1 in the layout of
+   the RES polyhedron: T1|I1|T2|I2|S1|S2|G.  DIRECTION is equal to 1
+   when statement 1 is after statement 2, equal to -1 when statement 1
+   is before statement 2.  */
 
 static void
 build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res,
 				       graphite_dim_t dim,
-				       graphite_dim_t tdim1,
+				       graphite_dim_t tdim,
 				       graphite_dim_t offset,
 				       int direction)
 {
@@ -299,19 +312,21 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
   if (lexicographically_gt_p (*res, dim, offset, direction, 0))
     return;
 
-  for (i = 0; i < tdim1 - 1; i++)
+  for (i = 0; i < tdim - 1; i++)
     {
       ppl_Pointset_Powerset_C_Polyhedron_t sceq;
 
+      /* All the dimensions up to I are equal, ...  */
       sceq = build_pairwise_scheduling (dim, i, offset, 0);
       ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, sceq);
       ppl_delete_Pointset_Powerset_C_Polyhedron (sceq);
 
+      /* ... and at depth I+1 they are not equal anymore.  */
       if (lexicographically_gt_p (*res, dim, offset, direction, i + 1))
 	return;
     }
 
-  if (i == tdim1 - 1)
+  if (i == tdim - 1)
     {
       ppl_delete_Pointset_Powerset_C_Polyhedron (*res);
       ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (res, dim, 1);
@@ -327,14 +342,22 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
    | T1 and T2 the scattering dimensions for PDR1 and PDR2
    | I1 and I2 the iteration domains
    | S1 and S2 the subscripts
-   | G the global parameters.  */
+   | G the global parameters.
+
+   SCAT1 and SCAT2 are the scattering polyhedra for PDR1 and PDR2.
+   When ORIGINAL_SCATTERING_P is true, then the scattering polyhedra
+   SCAT1 and SCAT2 correspond to the original scattering of the
+   program, otherwise they correspond to the transformed scattering.
+
+   DIRECTION is equal to 1 when statement 1 is after statement 2,
+   equal to -1 when statement 1 is before statement 2.  */
 
 static poly_ddr_p
 dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
 		         ppl_Pointset_Powerset_C_Polyhedron_t d1,
 		         ppl_Pointset_Powerset_C_Polyhedron_t d2,
 		         poly_dr_p pdr1, poly_dr_p pdr2,
-	                 ppl_Polyhedron_t s1, ppl_Polyhedron_t s2,
+	                 ppl_Polyhedron_t scat1, ppl_Polyhedron_t scat2,
 		         int direction,
 		         bool original_scattering_p)
 {
@@ -361,8 +384,8 @@ dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
     (&context, SCOP_CONTEXT (scop));
   ppl_insert_dimensions_pointset (context, 0, dim - gdim);
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc1, s1);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc2, s2);
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc1, scat1);
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc2, scat2);
 
   id1 = map_into_dep_poly (dim, gdim, d1, ddim1, tdim1);
   id2 = map_into_dep_poly (dim, gdim, d2, ddim2, tdim1 + ddim1 + tdim2);
@@ -405,14 +428,22 @@ dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
 }
 
 /* Build the dependence polyhedron for data references PDR1 and PDR2.
-   If possible use already cached information.  */
+   If possible use already cached information.
+
+   SCAT1 and SCAT2 are the scattering polyhedra for PDR1 and PDR2.
+   When ORIGINAL_SCATTERING_P is true, then the scattering polyhedra
+   SCAT1 and SCAT2 correspond to the original scattering of the
+   program, otherwise they correspond to the transformed scattering.
+
+   DIRECTION is equal to 1 when statement 1 is after statement 2,
+   equal to -1 when statement 1 is before statement 2.  */
 
 static poly_ddr_p
 dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
 		       ppl_Pointset_Powerset_C_Polyhedron_t d1,
 		       ppl_Pointset_Powerset_C_Polyhedron_t d2,
 		       poly_dr_p pdr1, poly_dr_p pdr2,
-	               ppl_Polyhedron_t s1, ppl_Polyhedron_t s2,
+	               ppl_Polyhedron_t scat1, ppl_Polyhedron_t scat2,
 		       int direction,
 		       bool original_scattering_p)
 {
@@ -433,7 +464,7 @@ dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
     }
 
   res = dependence_polyhedron_1 (pbb1, pbb2, d1, d2, pdr1, pdr2,
-                                 s1, s2, direction, original_scattering_p);
+                                 scat1, scat2, direction, original_scattering_p);
 
   if (original_scattering_p)
     *x = res;
-- 
1.6.3.3

>From e44cce40569f15341bc2e7eff2f6793a427640ea Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Jan 2010 06:22:26 +0000
Subject: [PATCH 04/13] Fix build_pddr.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (pddr_original_scattering): Renamed build_pddr.
	(pddr_transformed_scattering): Removed.
	(graphite_legal_transform_dr): Use build_pddr.
	(dot_original_deps_stmt_1): Same.
	(dot_transformed_deps_stmt_1): Same.
	(dot_original_deps): Same.
	(dot_transformed_deps): Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156061 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite     |   10 +++++
 gcc/graphite-dependences.c |   80 +++++++++++++++++--------------------------
 2 files changed, 42 insertions(+), 48 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 8d26291..8a5157a 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,15 @@
 2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-dependences.c (pddr_original_scattering): Renamed build_pddr.
+	(pddr_transformed_scattering): Removed.
+	(graphite_legal_transform_dr): Use build_pddr.
+	(dot_original_deps_stmt_1): Same.
+	(dot_transformed_deps_stmt_1): Same.
+	(dot_original_deps): Same.
+	(dot_transformed_deps): Same.
+
+2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (lexicographically_gt_p): Add comments.
 	(build_lexicographically_gt_constraint): Same.
 	(dependence_polyhedron_1): Same.
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index e096cba..3da2557 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -344,6 +344,8 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
    | S1 and S2 the subscripts
    | G the global parameters.
 
+   D1 and D2 are the iteration domains of PDR1 and PDR2.
+
    SCAT1 and SCAT2 are the scattering polyhedra for PDR1 and PDR2.
    When ORIGINAL_SCATTERING_P is true, then the scattering polyhedra
    SCAT1 and SCAT2 correspond to the original scattering of the
@@ -430,6 +432,8 @@ dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
 /* Build the dependence polyhedron for data references PDR1 and PDR2.
    If possible use already cached information.
 
+   D1 and D2 are the iteration domains of PDR1 and PDR2.
+
    SCAT1 and SCAT2 are the scattering polyhedra for PDR1 and PDR2.
    When ORIGINAL_SCATTERING_P is true, then the scattering polyhedra
    SCAT1 and SCAT2 correspond to the original scattering of the
@@ -472,64 +476,38 @@ dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
   return res;
 }
 
-static bool
-poly_drs_may_alias_p (poly_dr_p pdr1, poly_dr_p pdr2);
-
-/* Returns the PDDR corresponding to the original schedule, or NULL if
-   the dependence relation is empty or unknown (cannot judge dependency
-   under polyhedral model).  */
+/* Returns the Polyhedral Data Dependence Relation (PDDR) between PDR1
+   contained in PBB1 and PDR2 contained in PBB2.  When
+   ORIGINAL_SCATTERING_P is true, return the PDDR corresponding to the
+   original scattering, or NULL if the dependence relation is empty.
+   When ORIGINAL_SCATTERING_P is false, return the PDDR corresponding
+   to the transformed scattering.  */
 
 static poly_ddr_p
-pddr_original_scattering (poly_bb_p pbb1, poly_bb_p pbb2,
-			  poly_dr_p pdr1, poly_dr_p pdr2)
+build_pddr (poly_bb_p pbb1, poly_bb_p pbb2, poly_dr_p pdr1, poly_dr_p pdr2,
+	    bool original_scattering_p)
 {
   poly_ddr_p pddr;
   ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
   ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
-  ppl_Polyhedron_t so1 = PBB_ORIGINAL_SCATTERING (pbb1);
-  ppl_Polyhedron_t so2 = PBB_ORIGINAL_SCATTERING (pbb2);
+  ppl_Polyhedron_t scat1 = original_scattering_p ?
+    PBB_ORIGINAL_SCATTERING (pbb1) : PBB_TRANSFORMED_SCATTERING (pbb1);
+  ppl_Polyhedron_t scat2 = original_scattering_p ?
+    PBB_ORIGINAL_SCATTERING (pbb2) : PBB_TRANSFORMED_SCATTERING (pbb2);
 
   if ((pdr_read_p (pdr1) && pdr_read_p (pdr2))
       || PDR_BASE_OBJECT_SET (pdr1) != PDR_BASE_OBJECT_SET (pdr2)
       || PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2))
     return NULL;
 
-  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
-				1, true);
+  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, scat1, scat2,
+				1, original_scattering_p);
   if (pddr_is_empty (pddr))
     return NULL;
 
   return pddr;
 }
 
-/* Returns the PDDR corresponding to the transformed schedule, or NULL if
-   the dependence relation is empty or unknown (cannot judge dependency
-   under polyhedral model).  */
-
-static poly_ddr_p
-pddr_transformed_scattering (poly_bb_p pbb1, poly_bb_p pbb2,
-			     poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  poly_ddr_p pddr;
-  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
-  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
-  ppl_Polyhedron_t st1 = PBB_ORIGINAL_SCATTERING (pbb1);
-  ppl_Polyhedron_t st2 = PBB_ORIGINAL_SCATTERING (pbb2);
-
-  if ((pdr_read_p (pdr1) && pdr_read_p (pdr2))
-      || PDR_BASE_OBJECT_SET (pdr1) != PDR_BASE_OBJECT_SET (pdr2)
-      || PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2))
-    return NULL;
-
-  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, st1, st2,
-				1, false);
-  if (pddr_is_empty (pddr))
-    return NULL;
-
-  return pddr;
-}
-
-
 /* Return true when the data dependence relation between the data
    references PDR1 belonging to PBB1 and PDR2 is part of a
    reduction.  */
@@ -585,7 +563,7 @@ graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
   if (reduction_dr_p (pbb1, pbb2, pdr1, pdr2))
     return true;
 
-  pddr = pddr_original_scattering (pbb1, pbb2, pdr1, pdr2);
+  pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, true);
   if (!pddr)
     return true;
 
@@ -833,7 +811,7 @@ dot_original_deps_stmt_1 (FILE *file, scop_p scop)
       {
 	for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	  for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	    if (pddr_original_scattering (pbb1, pbb2, pdr1, pdr2))
+	    if (build_pddr (pbb1, pbb2, pdr1, pdr2, true))
 	      {
 		fprintf (file, "OS%d -> OS%d\n",
 			 pbb_index (pbb1), pbb_index (pbb2));
@@ -852,16 +830,18 @@ dot_transformed_deps_stmt_1 (FILE *file, scop_p scop)
   int i, j, k, l;
   poly_bb_p pbb1, pbb2;
   poly_dr_p pdr1, pdr2;
+  poly_ddr_p pddr;
 
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb1); i++)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       {
 	for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	  for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	    if (pddr_transformed_scattering (pbb1, pbb2, pdr1, pdr2))
+	    if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, false)))
 	      {
 		fprintf (file, "TS%d -> TS%d\n",
 			 pbb_index (pbb1), pbb_index (pbb2));
+		free_poly_ddr (pddr);
 		goto done;
 	      }
       done:;
@@ -897,7 +877,7 @@ dot_original_deps (FILE *file, scop_p scop)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	  if (pddr_original_scattering (pbb1, pbb2, pdr1, pdr2))
+	  if (build_pddr (pbb1, pbb2, pdr1, pdr2, true))
 	    fprintf (file, "OS%d_D%d -> OS%d_D%d\n",
 		     pbb_index (pbb1), PDR_ID (pdr1),
 		     pbb_index (pbb2), PDR_ID (pdr2));
@@ -912,15 +892,19 @@ dot_transformed_deps (FILE *file, scop_p scop)
   int i, j, k, l;
   poly_bb_p pbb1, pbb2;
   poly_dr_p pdr1, pdr2;
+  poly_ddr_p pddr;
 
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb1); i++)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	  if (pddr_transformed_scattering (pbb1, pbb2, pdr1, pdr2))
-	    fprintf (file, "TS%d_D%d -> TS%d_D%d\n",
-		     pbb_index (pbb1), PDR_ID (pdr1),
-		     pbb_index (pbb2), PDR_ID (pdr2));
+	  if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, false)))
+	    {
+	      fprintf (file, "TS%d_D%d -> TS%d_D%d\n",
+		       pbb_index (pbb1), PDR_ID (pdr1),
+		       pbb_index (pbb2), PDR_ID (pdr2));
+	      free_poly_ddr (pddr);
+	    }
 }
 
 /* Pretty print to FILE all the data dependences of SCoP in DOT
-- 
1.6.3.3

>From d41226999b304328b2791bee95085727a3ea0c57 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Jan 2010 22:58:19 +0000
Subject: [PATCH 05/13] Clarify comments and use build_pddr.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c: Clarify comments.
	(build_pddr): Add an extra parameter direction.
	(graphite_legal_transform_dr): Use build_pddr.
	(dot_original_deps_stmt_1): Update use of build_pddr.
	(dot_transformed_deps_stmt_1): Same.
	(dot_original_deps): Same.
	(dot_transformed_deps): Same.

	* testsuite/gcc.dg/graphite/interchange-12.c: New.
	* gcc/testsuite/gcc.dg/graphite/block-7.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156093 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite                         |   13 ++++++
 gcc/graphite-dependences.c                     |   52 +++++++++++++++---------
 gcc/testsuite/gcc.dg/graphite/block-7.c        |   19 +++++++++
 gcc/testsuite/gcc.dg/graphite/interchange-12.c |   19 +++++++++
 4 files changed, 84 insertions(+), 19 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/graphite/block-7.c
 create mode 100644 gcc/testsuite/gcc.dg/graphite/interchange-12.c

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 8a5157a..03009a9 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,18 @@
 2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-dependences.c: Clarify comments.
+	(build_pddr): Add an extra parameter direction.
+	(graphite_legal_transform_dr): Use build_pddr.
+	(dot_original_deps_stmt_1): Update use of build_pddr.
+	(dot_transformed_deps_stmt_1): Same.
+	(dot_original_deps): Same.
+	(dot_transformed_deps): Same.
+
+	* testsuite/gcc.dg/graphite/interchange-12.c: New.
+	* testsuite/gcc.dg/graphite/block-7.c: New.
+
+2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (pddr_original_scattering): Renamed build_pddr.
 	(pddr_transformed_scattering): Removed.
 	(graphite_legal_transform_dr): Use build_pddr.
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 3da2557..7b462f7 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -296,9 +296,10 @@ lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res,
    compared lexicographically, i.e. the number of loops containing
    both statements.  OFFSET is the number of dimensions needed to
    represent the first statement, i.e. dimT1 + dimI1 in the layout of
-   the RES polyhedron: T1|I1|T2|I2|S1|S2|G.  DIRECTION is equal to 1
-   when statement 1 is after statement 2, equal to -1 when statement 1
-   is before statement 2.  */
+   the RES polyhedron: T1|I1|T2|I2|S1|S2|G.  When DIRECTION is set to
+   1, compute the direct dependence from PDR1 to PDR2, and when
+   DIRECTION is -1, compute the reversed dependence relation, from
+   PDR2 to PDR1.  */
 
 static void
 build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res,
@@ -351,8 +352,9 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
    SCAT1 and SCAT2 correspond to the original scattering of the
    program, otherwise they correspond to the transformed scattering.
 
-   DIRECTION is equal to 1 when statement 1 is after statement 2,
-   equal to -1 when statement 1 is before statement 2.  */
+   When DIRECTION is set to 1, compute the direct dependence from PDR1
+   to PDR2, and when DIRECTION is -1, compute the reversed dependence
+   relation, from PDR2 to PDR1.  */
 
 static poly_ddr_p
 dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
@@ -439,8 +441,9 @@ dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
    SCAT1 and SCAT2 correspond to the original scattering of the
    program, otherwise they correspond to the transformed scattering.
 
-   DIRECTION is equal to 1 when statement 1 is after statement 2,
-   equal to -1 when statement 1 is before statement 2.  */
+   When DIRECTION is set to 1, compute the direct dependence from PDR1
+   to PDR2, and when DIRECTION is -1, compute the reversed dependence
+   relation, from PDR2 to PDR1.  */
 
 static poly_ddr_p
 dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
@@ -481,11 +484,13 @@ dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
    ORIGINAL_SCATTERING_P is true, return the PDDR corresponding to the
    original scattering, or NULL if the dependence relation is empty.
    When ORIGINAL_SCATTERING_P is false, return the PDDR corresponding
-   to the transformed scattering.  */
+   to the transformed scattering.  When DIRECTION is set to 1, compute
+   the direct dependence from PDR1 to PDR2, and when DIRECTION is -1,
+   compute the reversed dependence relation, from PDR2 to PDR1.  */
 
 static poly_ddr_p
 build_pddr (poly_bb_p pbb1, poly_bb_p pbb2, poly_dr_p pdr1, poly_dr_p pdr2,
-	    bool original_scattering_p)
+	    int direction, bool original_scattering_p)
 {
   poly_ddr_p pddr;
   ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
@@ -501,7 +506,7 @@ build_pddr (poly_bb_p pbb1, poly_bb_p pbb2, poly_dr_p pdr1, poly_dr_p pdr2,
     return NULL;
 
   pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, scat1, scat2,
-				1, original_scattering_p);
+				direction, original_scattering_p);
   if (pddr_is_empty (pddr))
     return NULL;
 
@@ -557,14 +562,14 @@ graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
   ppl_dimension_type pdim;
   bool is_empty_p;
   poly_ddr_p pddr;
-  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
-  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
 
   if (reduction_dr_p (pbb1, pbb2, pdr1, pdr2))
     return true;
 
-  pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, true);
+  pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, 1, true);
   if (!pddr)
+    /* There are no dependences between PDR1 and PDR2 in the original
+       version of the program, so the transform is legal.  */
     return true;
 
   po = PDDR_DDP (pddr);
@@ -587,8 +592,17 @@ graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
   ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&temp, pdim, 0);
   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (temp, po);
 
-  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, st1, st2,
-				-1, false);
+  /* We build the reverse dependence relation for the transformed
+     scattering, such that when we intersect it with the original PO,
+     we get an empty intersection when the transform is legal:
+     i.e. the transform should reverse no dependences, and so PT, the
+     reversed transformed PDDR, should have no constraint from PO.  */
+  pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, -1, false);
+  if (!pddr)
+    /* There are no dependences after the transform, so the transform
+       is legal.  */
+    return true;
+
   pt = PDDR_DDP (pddr);
 
   /* Extend PO and PT to have the same dimensions.  */
@@ -811,7 +825,7 @@ dot_original_deps_stmt_1 (FILE *file, scop_p scop)
       {
 	for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	  for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	    if (build_pddr (pbb1, pbb2, pdr1, pdr2, true))
+	    if (build_pddr (pbb1, pbb2, pdr1, pdr2, 1, true))
 	      {
 		fprintf (file, "OS%d -> OS%d\n",
 			 pbb_index (pbb1), pbb_index (pbb2));
@@ -837,7 +851,7 @@ dot_transformed_deps_stmt_1 (FILE *file, scop_p scop)
       {
 	for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	  for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	    if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, false)))
+	    if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, 1, false)))
 	      {
 		fprintf (file, "TS%d -> TS%d\n",
 			 pbb_index (pbb1), pbb_index (pbb2));
@@ -877,7 +891,7 @@ dot_original_deps (FILE *file, scop_p scop)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	  if (build_pddr (pbb1, pbb2, pdr1, pdr2, true))
+	  if (build_pddr (pbb1, pbb2, pdr1, pdr2, 1, true))
 	    fprintf (file, "OS%d_D%d -> OS%d_D%d\n",
 		     pbb_index (pbb1), PDR_ID (pdr1),
 		     pbb_index (pbb2), PDR_ID (pdr2));
@@ -898,7 +912,7 @@ dot_transformed_deps (FILE *file, scop_p scop)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	  if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, false)))
+	  if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, 1, false)))
 	    {
 	      fprintf (file, "TS%d_D%d -> TS%d_D%d\n",
 		       pbb_index (pbb1), PDR_ID (pdr1),
diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c
new file mode 100644
index 0000000..994a55a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/block-7.c
@@ -0,0 +1,19 @@
+#define N 1000
+
+float A[N][N], B[N][N], C[N][N];
+
+void matmult ()
+{
+  int i, j, k;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      {
+        A[i][j] = 0;
+        for (k = 0; k < N; k++)
+          A[i][j] += B[i][k] * C[k][j];
+      }
+}
+
+/* { dg-final { scan-tree-dump-times "SCoP will be loop blocked" 1 "graphite" } } */
+/* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
new file mode 100644
index 0000000..73c9c8c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
@@ -0,0 +1,19 @@
+#define N 1000
+
+float A[N][N], B[N][N], C[N][N];
+
+void matmult ()
+{
+  int i, j, k;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      {
+        A[i][j] = 0;
+        for (k = 0; k < N; k++)
+          A[i][j] += B[i][k] * C[k][j];
+      }
+}
+
+/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
+/* { dg-final { cleanup-tree-dump "graphite" } } */
-- 
1.6.3.3

>From 0cda3d698faf02324b569d3397496e74d043fa21 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 20 Jan 2010 23:36:06 +0000
Subject: [PATCH 06/13] Add more testcases.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* testsuite/gcc.dg/graphite/id-17.c: New.
	* testsuite/gcc.dg/graphite/pr41888.c: New.
	* testsuite/gcc.dg/graphite/scop-22.c: New.
	* testsuite/gfortran.dg/graphite/pr40982.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156095 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite                         |    7 +++
 gcc/testsuite/gcc.dg/graphite/id-17.c          |   21 +++++++
 gcc/testsuite/gcc.dg/graphite/pr41888.c        |   18 ++++++
 gcc/testsuite/gcc.dg/graphite/scop-22.c        |   21 +++++++
 gcc/testsuite/gfortran.dg/graphite/pr40982.f90 |   69 ++++++++++++++++++++++++
 5 files changed, 136 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/graphite/id-17.c
 create mode 100644 gcc/testsuite/gcc.dg/graphite/pr41888.c
 create mode 100644 gcc/testsuite/gcc.dg/graphite/scop-22.c
 create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr40982.f90

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 03009a9..b398dd5 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,12 @@
 2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* testsuite/gcc.dg/graphite/id-17.c: New.
+	* testsuite/gcc.dg/graphite/pr41888.c: New.
+	* testsuite/gcc.dg/graphite/scop-22.c: New.
+	* testsuite/gfortran.dg/graphite/pr40982.f90: New.
+
+2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c: Clarify comments.
 	(build_pddr): Add an extra parameter direction.
 	(graphite_legal_transform_dr): Use build_pddr.
diff --git a/gcc/testsuite/gcc.dg/graphite/id-17.c b/gcc/testsuite/gcc.dg/graphite/id-17.c
new file mode 100644
index 0000000..c93c211
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/id-17.c
@@ -0,0 +1,21 @@
+typedef struct
+{
+  int offset_for_ref_frame[256];
+} seq_parameter_set_rbsp_t;
+
+typedef struct
+{
+  unsigned int num_ref_frames_in_pic_order_cnt_cycle;
+  int offset_for_ref_frame[1];
+  int auto_crop_right;
+} ImageParameters;
+
+ImageParameters *img;
+
+void GenerateSequenceParameterSet(seq_parameter_set_rbsp_t *sps)
+{
+  unsigned i;
+  for (i=0; i<img->num_ref_frames_in_pic_order_cnt_cycle; i++)
+    sps->offset_for_ref_frame[i] = img->offset_for_ref_frame[i];
+ error("foo");
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr41888.c b/gcc/testsuite/gcc.dg/graphite/pr41888.c
new file mode 100644
index 0000000..b262af6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr41888.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-g -O2 -ftree-loop-distribution -fgraphite-identity" } */
+
+int
+foo (int *x)
+{
+  int a[10], b[10];
+  int i;
+  a[9] = 8;
+  b[9] = 8;
+  for (i = 0; i < 9; i++)
+    {
+      a[i] = *x++;
+      b[i] = 1;
+    }
+  b[i] = b[i] & !(a[i] ^ *x++);
+  return b[i] ? i + 1 : 0;
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-22.c b/gcc/testsuite/gcc.dg/graphite/scop-22.c
new file mode 100644
index 0000000..b77be22
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/scop-22.c
@@ -0,0 +1,21 @@
+double u[1782225];
+
+void foo(int N, int *res)
+{
+  int i;
+  double a, b;
+  double sum = 0.0;
+
+  for (i = 0; i < N; i++)
+    {
+      a = u[i];
+      u[i] = i * i;
+      b = u[i];
+      sum += a + b;
+    }
+
+  *res = sum + N;
+}
+
+/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */
+/* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr40982.f90 b/gcc/testsuite/gfortran.dg/graphite/pr40982.f90
new file mode 100644
index 0000000..b9641ae
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/graphite/pr40982.f90
@@ -0,0 +1,69 @@
+! { dg-options "-O3 -fgraphite-identity -floop-interchange " }
+
+module mqc_m
+
+
+implicit none
+
+private
+public :: mutual_ind_quad_cir_coil
+
+integer, parameter, private :: longreal = selected_real_kind(15,90)
+real (kind = longreal), parameter, private :: pi = 3.141592653589793_longreal
+real (kind = longreal), parameter, private :: small = 1.0e-10_longreal
+
+contains
+
+      subroutine mutual_ind_quad_cir_coil (r_coil, x_coil, y_coil, z_coil, h_coil, n_coil,  &
+                                                      rotate_coil, m, mu, l12)
+      real (kind = longreal), intent(in) :: r_coil, x_coil, y_coil, z_coil, h_coil, n_coil, &
+                                            mu
+      real (kind = longreal), dimension(:,:), intent(in) :: rotate_coil
+      integer, intent(in) :: m
+      real (kind = longreal), intent(out) :: l12
+      real (kind = longreal), dimension(3,3) :: rotate_quad
+      real (kind = longreal), dimension(9), save :: x2gauss, y2gauss, w2gauss, z1gauss,     &
+                                                    w1gauss
+      real (kind = longreal) :: xxvec, xyvec, xzvec, yxvec, yyvec, yzvec, zxvec, zyvec,     &
+                                zzvec, magnitude, l12_lower, l12_upper, dx, dy, dz, theta,  &
+                                a, b1, b2, numerator, denominator, coefficient, angle
+      real (kind = longreal), dimension(3) :: c_vector, q_vector, rot_c_vector,             &
+                                              rot_q_vector, current_vector,                 &
+                                              coil_current_vec, coil_tmp_vector
+      integer :: i, j, k
+      logical, save :: first = .true.
+
+      do i = 1, 2*m
+          theta = pi*real(i,longreal)/real(m,longreal)
+          c_vector(1) = r_coil * cos(theta)
+          c_vector(2) = r_coil * sin(theta)
+          coil_tmp_vector(1) = -sin(theta)
+          coil_tmp_vector(2) = cos(theta)
+          coil_tmp_vector(3) = 0.0_longreal
+          coil_current_vec(1) = dot_product(rotate_coil(1,:),coil_tmp_vector(:))
+          coil_current_vec(2) = dot_product(rotate_coil(2,:),coil_tmp_vector(:))
+          coil_current_vec(3) = dot_product(rotate_coil(3,:),coil_tmp_vector(:))
+          do j = 1, 9
+              c_vector(3) = 0.5 * h_coil * z1gauss(j)
+              rot_c_vector(1) = dot_product(rotate_coil(1,:),c_vector(:)) + dx
+              rot_c_vector(2) = dot_product(rotate_coil(2,:),c_vector(:)) + dy
+              rot_c_vector(3) = dot_product(rotate_coil(3,:),c_vector(:)) + dz
+              do k = 1, 9
+                  q_vector(1) = 0.5_longreal * a * (x2gauss(k) + 1.0_longreal)
+                  q_vector(2) = 0.5_longreal * b1 * (y2gauss(k) - 1.0_longreal)
+                  q_vector(3) = 0.0_longreal
+                  rot_q_vector(1) = dot_product(rotate_quad(1,:),q_vector(:))
+                  rot_q_vector(2) = dot_product(rotate_quad(2,:),q_vector(:))
+                  rot_q_vector(3) = dot_product(rotate_quad(3,:),q_vector(:))
+                  numerator = w1gauss(j) * w2gauss(k) *                                     &
+                                                 dot_product(coil_current_vec,current_vector)
+                  denominator = sqrt(dot_product(rot_c_vector-rot_q_vector,                 &
+                                                                  rot_c_vector-rot_q_vector))
+                  l12_lower = l12_lower + numerator/denominator
+              end do
+          end do
+      end do
+      l12 = coefficient * (b1 * l12_lower + b2 * l12_upper)
+      end subroutine mutual_ind_quad_cir_coil
+
+end module mqc_m
-- 
1.6.3.3

>From b8e05a5304cf1331c53582d13cbc7e6b18853909 Mon Sep 17 00:00:00 2001
From: uramakrishna <uramakrishna@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 22 Jan 2010 15:25:39 +0000
Subject: [PATCH 07/13] Add flag to dis/enable cloog optimization.

2010-01-22  Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>

	* common.opt: Add -fgraphite-cloog-opts.
	* graphite-clast-to-gimple.c (set_cloog_options): Same.
	* opts.c (decode_options): Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156173 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index b398dd5..ca8f20f 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,9 @@
+2010-01-22  Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>
+
+	* common.opt: Add -fgraphite-cloog-opts.
+	* graphite-clast-to-gimple.c (set_cloog_options): Same.
+	* opts.c (decode_options): Same.
+
 2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* testsuite/gcc.dg/graphite/id-17.c: New.
-- 
1.6.3.3

>From 8232069b0913aa86a88b2b109c56837067938248 Mon Sep 17 00:00:00 2001
From: uramakrishna <uramakrishna@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 22 Jan 2010 16:22:58 +0000
Subject: [PATCH 08/13] Make calls to dot run in background.

2010-01-22  Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>

	* graphite-scop-detection.c (dot_all_scops): Make calls to dot run in
	  background.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156174 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite        |    5 +++++
 gcc/graphite-scop-detection.c |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index ca8f20f..83b8b1c 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,10 @@
 2010-01-22  Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>
 
+	* graphite-scop-detection.c (dot_all_scops): Make calls to dot run in
+	  background.
+
+2010-01-22  Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>
+
 	* common.opt: Add -fgraphite-cloog-opts.
 	* graphite-clast-to-gimple.c (set_cloog_options): Same.
 	* opts.c (decode_options): Same.
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 8fd7b54..ddd1121 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1497,7 +1497,7 @@ dot_all_scops (VEC (scop_p, heap) *scops)
   dot_all_scops_1 (stream, scops);
   fclose (stream);
 
-  x = system ("dotty /tmp/allscops.dot");
+  x = system ("dotty /tmp/allscops.dot &");
 #else
   dot_all_scops_1 (stderr, scops);
 #endif
@@ -1523,7 +1523,7 @@ dot_scop (scop_p scop)
 
     dot_all_scops_1 (stream, scops);
     fclose (stream);
-    x = system ("dotty /tmp/allscops.dot");
+    x = system ("dotty /tmp/allscops.dot &");
   }
 #else
   dot_all_scops_1 (stderr, scops);
-- 
1.6.3.3

>From f63b3576e87167d11674524179d089ffd1062946 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Feb 2010 19:23:11 +0000
Subject: [PATCH 09/13] Add runtime tests for interchange and blocking.

2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>

	* testsuite/g++.dg/graphite/graphite.exp: Rewritten.
	* testsuite/gcc.dg/graphite/graphite.exp: Rewritten.
	* testsuite/gfortran.dg/graphite/graphite.exp: Rewritten.
	* gcc/testsuite/gcc.dg/graphite/block-0.c: Added runtime test.
	* testsuite/gcc.dg/graphite/block-1.c: Same.
	* testsuite/gcc.dg/graphite/block-3.c: Same.
	* testsuite/gcc.dg/graphite/block-4.c: Same.
	* testsuite/gcc.dg/graphite/block-5.c: Same.
	* testsuite/gcc.dg/graphite/block-6.c: Same.
	* testsuite/gcc.dg/graphite/block-7.c: Same.
	* testsuite/gcc.dg/graphite/interchange-0.c: Same.
	* testsuite/gcc.dg/graphite/interchange-1.c: Same.
	* testsuite/gcc.dg/graphite/interchange-10.c: Same.
	* testsuite/gcc.dg/graphite/interchange-11.c: Same.
	* testsuite/gcc.dg/graphite/interchange-12.c: Same.
	* testsuite/gcc.dg/graphite/interchange-2.c: Same.
	* testsuite/gcc.dg/graphite/interchange-3.c: Same.
	* testsuite/gcc.dg/graphite/interchange-4.c: Same.
	* testsuite/gcc.dg/graphite/interchange-5.c: Same.
	* testsuite/gcc.dg/graphite/interchange-6.c: Same.
	* testsuite/gcc.dg/graphite/interchange-7.c: Same.
	* testsuite/gcc.dg/graphite/interchange-8.c: Same.
	* testsuite/gcc.dg/graphite/interchange-9.c: Same.
	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
	* testsuite/gcc.dg/graphite/run-id-2.c: Remove useless dg-do run.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156473 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite                          |   28 +++++++++++
 gcc/testsuite/g++.dg/graphite/graphite.exp      |   58 +++++++---------------
 gcc/testsuite/gcc.dg/graphite/block-0.c         |   24 ++++++++--
 gcc/testsuite/gcc.dg/graphite/block-1.c         |   17 ++++---
 gcc/testsuite/gcc.dg/graphite/block-3.c         |   33 ++++++++++++-
 gcc/testsuite/gcc.dg/graphite/block-4.c         |   39 +++++++++++++--
 gcc/testsuite/gcc.dg/graphite/block-5.c         |   48 ++++++++++++++----
 gcc/testsuite/gcc.dg/graphite/block-6.c         |   47 +++++++++++++-----
 gcc/testsuite/gcc.dg/graphite/block-7.c         |   38 +++++++++++++-
 gcc/testsuite/gcc.dg/graphite/graphite.exp      |   58 +++++++---------------
 gcc/testsuite/gcc.dg/graphite/interchange-0.c   |   38 ++++++++++++--
 gcc/testsuite/gcc.dg/graphite/interchange-1.c   |   30 +++++++++++-
 gcc/testsuite/gcc.dg/graphite/interchange-10.c  |   30 +++++++++++-
 gcc/testsuite/gcc.dg/graphite/interchange-11.c  |   28 ++++++++++-
 gcc/testsuite/gcc.dg/graphite/interchange-12.c  |   38 +++++++++++++-
 gcc/testsuite/gcc.dg/graphite/interchange-2.c   |   31 +++++++++++-
 gcc/testsuite/gcc.dg/graphite/interchange-3.c   |   39 ++++++++++++---
 gcc/testsuite/gcc.dg/graphite/interchange-4.c   |   29 ++++++++++-
 gcc/testsuite/gcc.dg/graphite/interchange-5.c   |   39 +++++++++++++--
 gcc/testsuite/gcc.dg/graphite/interchange-6.c   |   39 +++++++++++++--
 gcc/testsuite/gcc.dg/graphite/interchange-7.c   |   38 +++++++++++++--
 gcc/testsuite/gcc.dg/graphite/interchange-8.c   |   43 +++++++++++++++--
 gcc/testsuite/gcc.dg/graphite/interchange-9.c   |   36 ++++++++++++--
 gcc/testsuite/gcc.dg/graphite/interchange-mvt.c |   59 ++++++++++++++++++-----
 gcc/testsuite/gcc.dg/graphite/run-id-2.c        |    5 +-
 gcc/testsuite/gfortran.dg/graphite/graphite.exp |   56 +++++++---------------
 26 files changed, 739 insertions(+), 229 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 83b8b1c..fe9962c 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,31 @@
+2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* testsuite/g++.dg/graphite/graphite.exp: Rewritten.
+	* testsuite/gcc.dg/graphite/graphite.exp: Rewritten.
+	* testsuite/gfortran.dg/graphite/graphite.exp: Rewritten.
+	* gcc/testsuite/gcc.dg/graphite/block-0.c: Added runtime test.
+	* testsuite/gcc.dg/graphite/block-1.c: Same.
+	* testsuite/gcc.dg/graphite/block-3.c: Same.
+	* testsuite/gcc.dg/graphite/block-4.c: Same.
+	* testsuite/gcc.dg/graphite/block-5.c: Same.
+	* testsuite/gcc.dg/graphite/block-6.c: Same.
+	* testsuite/gcc.dg/graphite/block-7.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-0.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-1.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-10.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-11.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-12.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-2.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-3.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-4.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-5.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-6.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-7.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-8.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-9.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
+	* testsuite/gcc.dg/graphite/run-id-2.c: Remove useless dg-do run.
+
 2010-01-22  Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>
 
 	* graphite-scop-detection.c (dot_all_scops): Make calls to dot run in
diff --git a/gcc/testsuite/g++.dg/graphite/graphite.exp b/gcc/testsuite/g++.dg/graphite/graphite.exp
index ba7c8cc..f46dcc7 100644
--- a/gcc/testsuite/g++.dg/graphite/graphite.exp
+++ b/gcc/testsuite/g++.dg/graphite/graphite.exp
@@ -33,58 +33,36 @@ proc lremove {list_variable value} {
 # The default action for a test is 'compile'.  Save current default.
 global dg-do-what-default
 set save-dg-do-what-default ${dg-do-what-default}
-set dg-do-what-default compile
 
 # Initialize `dg'.
 dg-init
 
-# Main loop.
-
 set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.C ] ]
-
-# Flags using for block-* files.
-set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
- -fno-loop-interchange -fdump-tree-graphite-all"
-set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ]
-dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK
-foreach block_file $block_files {lremove wait_to_run_files $block_file}
-
-# Flags using for id-* files.
-set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
-set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ]
-dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY
-foreach id_file $id_files {lremove wait_to_run_files $id_file}
-
-# Flags using for interchange-* files.
-set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
- -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
+set scop_files        [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ]
+set id_files          [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ]
+set run_id_files      [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ]
 set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.C ] ]
-dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE
-foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
-
-# Flags using for scop-* files.
-set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
-set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ]
-dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP
-foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
+set block_files       [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ]
 
+# Tests to be compiled.
+set dg-do-what-default compile
+dg-runtest $scop_files        "" "-O2 -fgraphite -fdump-tree-graphite-all"
+dg-runtest $id_files          "" "-O2 -fgraphite-identity -ffast-math"
 
-# Schedule now the tests to be run.
+# Tests to be run.
 set dg-do-what-default run
-
-# Flags using for run-id-* files.
-set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity"
-set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ]
-dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID
-foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
-
+dg-runtest $run_id_files      "" "-O2 -fgraphite-identity"
+dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
+dg-runtest $block_files       "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
 
 # The default action for the rest of the files is 'compile'.
 set dg-do-what-default compile
-
-# Flags using for other files.
-set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors"
-dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE
+foreach f $scop_files        {lremove wait_to_run_files $f}
+foreach f $id_files          {lremove wait_to_run_files $f}
+foreach f $run_id_files      {lremove wait_to_run_files $f}
+foreach f $interchange_files {lremove wait_to_run_files $f}
+foreach f $block_files       {lremove wait_to_run_files $f}
+dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors"
 
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c
index a00694c..112b889 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-0.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-0.c
@@ -1,11 +1,16 @@
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 #define N 1000
+int a[N];
 
-int toto()
+static int __attribute__((noinline))
+foo (void)
 {
   int j;
   int i;
-  int a[N];
-  int b[N];
 
   for (i = 0; i < N; i++)
     for (j = 0; j < N; j++)
@@ -16,7 +21,18 @@ int toto()
 
 main()
 {
-  return toto();
+  int i, res;
+
+  for (i = 0; i < N; i++)
+    a[i] = i;
+
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 1999;
 }
 
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-1.c b/gcc/testsuite/gcc.dg/graphite/block-1.c
index 35c5c6a..64ff67b 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-1.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-1.c
@@ -1,8 +1,11 @@
 /* { dg-require-effective-target size32plus } */
 
-#define MAX 8192
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
 
-void bar (void);
+#define MAX 100
 
 int main()
 {
@@ -11,8 +14,6 @@ int main()
   int A[MAX * MAX];
   int B[MAX * MAX];
 
-  bar ();
-
   for (i = 0; i < MAX; i++)
     for (j = 0; j < MAX; j++)
       {
@@ -24,13 +25,15 @@ int main()
     for (j = 0; j < MAX; j++)
       A[i*MAX + j] += B[j*MAX + i];
 
-  bar ();
-
   for(i = 0; i < MAX; i++)
     for(j = 0; j < MAX; j++)
       sum += A[i*MAX + j];
 
-  return sum;
+#if DEBUG
+  fprintf (stderr, "sum = %d \n", sum);
+#endif
+
+  return sum != 990000;
 }
 
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite" { xfail *-*-* } } } */ 
diff --git a/gcc/testsuite/gcc.dg/graphite/block-3.c b/gcc/testsuite/gcc.dg/graphite/block-3.c
index 7535616..01e1863 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-3.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-3.c
@@ -1,11 +1,17 @@
 /* { dg-require-effective-target size32plus } */
 
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 #define N 24
 #define M 100
 
-float A[M][M][M], B[M][M], C[M][M];
+int A[M][M][M], B[M][M], C[M][M];
 
-void test (void)
+static int __attribute__((noinline))
+foo (void)
 {
   int i, j, k;
 
@@ -20,6 +26,29 @@ void test (void)
     for (j = 0; j < M; j++)
       for (k = 0; k < M; k++)
         A[i][j][k] = B[i][k] * C[k][j];
+
+  return A[0][0][0] + A[M-1][M-1][M-1];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < M; i++)
+    for (j = 0; j < M; j++)
+      {
+	B[i][j] = i;
+	C[i][j] = j;
+      }
+
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 9801;
 }
 
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-4.c b/gcc/testsuite/gcc.dg/graphite/block-4.c
index d752a4d..3019f79 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-4.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-4.c
@@ -1,11 +1,17 @@
 /* { dg-require-effective-target size32plus } */
 
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 #define N 24
 #define M 1000
 
-float A[1000][1000], B[1000][1000], C[1000][1000];
+int A[M][M], B[M][M], C[M][M];
 
-void test (void)
+static int __attribute__((noinline))
+foo (void)
 {
   int i, j, k;
 
@@ -14,10 +20,33 @@ void test (void)
       for (k = 0; k < 24; k++)
         A[i][j] = B[i][k] * C[k][j];
 
-  for (i = 0; i < 1000; i++)
-    for (j = 0; j < 1000; j++)
-      for (k = 0; k < 1000; k++)
+  for (i = 0; i < M; i++)
+    for (j = 0; j < M; j++)
+      for (k = 0; k < M; k++)
         A[i][j] = B[i][k] * C[k][j];
+
+  return A[0][0] + A[M-1][M-1];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < M; i++)
+    for (j = 0; j < M; j++)
+      {
+	B[i][j] = i;
+	C[i][j] = j;
+      }
+
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 998001;
 }
 
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-5.c b/gcc/testsuite/gcc.dg/graphite/block-5.c
index a8f3817..4b99900 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-5.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-5.c
@@ -1,16 +1,20 @@
 /* { dg-require-effective-target size32plus } */
 
-#define N 10000
-void foo (int);
-int test ()
-{
-  int a[N][N];
-  int b[N][N];
-  unsigned i, j;
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
 
-  for (i = 0; i < N; i++)
-    for (j = 0; j < N; j++)
-      a[i][j] = i*j;
+#define N 200
+
+int a[N][N];
+int b[N][N];
+
+static int __attribute__((noinline))
+foo (void)
+{
+  int i, j;
+  int res = 0;
 
   /* This loop nest should be blocked.  */
   for (j = 1; j < N; j++)
@@ -18,8 +22,30 @@ int test ()
       a[i][j] = a[i][j-1] + b[i][j];
 
   for (i = 0; i < N; i++)
+    res += a[i][i];
+
+  return res;
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < N; i++)
     for (j = 0; j < N; j++)
-      foo (a[i][j]);
+      {
+	a[i][j] = i + j;
+	b[i][j] = i - j;
+      }
+
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 1333300;
 }
 
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-6.c b/gcc/testsuite/gcc.dg/graphite/block-6.c
index 6905e36..171b1df 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-6.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-6.c
@@ -1,25 +1,48 @@
 /* { dg-require-effective-target size32plus } */
 
-#define N 10000
-void foo (int);
-int test ()
-{
-  int a[N][N];
-  unsigned i, j;
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
 
-  for (i = 0; i < N; i++)
-    for (j = 0; j < N; j++)
-      a[i][j] = i*j;
+#define N 200
+int a[N][N];
+
+static int __attribute__((noinline))
+foo (void)
+{
+  int i, j;
+  int res = 0;
 
   /* Interchange is not legal for loops 0 and 1.  */
   for (i = 1; i < N; i++)
-    for (j = 1; j < (N-1) ; j++)
-      a[i][j] = a[i-1][j+1] * a[i-1][j+1]/2;
+    for (j = 1; j < N - 1; j++)
+      a[i][j] = a[i-1][j+1] * a[i-1][j+1] / 2;
+
+  for (i = 0; i < N; i++)
+    res += a[i][i];
+
+  return res;
+}
+
+int
+main (void)
+{
+  int i, j, res;
 
   for (i = 0; i < N; i++)
     for (j = 0; j < N; j++)
-      foo (a[i][j]);
+      a[i][j] = i + j;
+
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 204007516;
 }
 
+
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 0 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c
index 994a55a..3e8ff92 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-7.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-7.c
@@ -1,8 +1,16 @@
-#define N 1000
+/* { dg-require-effective-target size32plus } */
 
-float A[N][N], B[N][N], C[N][N];
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
 
-void matmult ()
+#define N 200
+
+int A[N][N], B[N][N], C[N][N];
+
+static void __attribute__((noinline))
+matmult (void)
 {
   int i, j, k;
 
@@ -15,5 +23,29 @@ void matmult ()
       }
 }
 
+int
+main (void)
+{
+  int i, j, res = 0;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      {
+	B[i][j] = j;
+	C[i][j] = i;
+      }
+
+  matmult ();
+
+  for (i = 0; i < N; i++)
+    res += A[i][i];
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 529340000;
+}
+
 /* { dg-final { scan-tree-dump-times "SCoP will be loop blocked" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/graphite.exp b/gcc/testsuite/gcc.dg/graphite/graphite.exp
index c4a8b2e..411e041 100644
--- a/gcc/testsuite/gcc.dg/graphite/graphite.exp
+++ b/gcc/testsuite/gcc.dg/graphite/graphite.exp
@@ -33,58 +33,36 @@ proc lremove {list_variable value} {
 # The default action for a test is 'compile'.  Save current default.
 global dg-do-what-default
 set save-dg-do-what-default ${dg-do-what-default}
-set dg-do-what-default compile
 
 # Initialize `dg'.
 dg-init
 
-# Main loop.
-
 set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.c ] ]
-
-# Flags using for block-* files.
-set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
- -fno-loop-interchange -fdump-tree-graphite-all"
-set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ]
-dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK
-foreach block_file $block_files {lremove wait_to_run_files $block_file}
-
-# Flags using for id-* files.
-set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
-set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ]
-dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY
-foreach id_file $id_files {lremove wait_to_run_files $id_file}
-
-# Flags using for interchange-* files.
-set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
- -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
+set scop_files        [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ]
+set id_files          [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ]
+set run_id_files      [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ]
 set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.c ] ]
-dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE
-foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
-
-# Flags using for scop-* files.
-set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
-set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ]
-dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP
-foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
+set block_files       [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ]
 
+# Tests to be compiled.
+set dg-do-what-default compile
+dg-runtest $scop_files        "" "-O2 -fgraphite -fdump-tree-graphite-all"
+dg-runtest $id_files          "" "-O2 -fgraphite-identity -ffast-math"
 
-# Schedule now the tests to be run.
+# Tests to be run.
 set dg-do-what-default run
-
-# Flags using for run-id-* files.
-set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity"
-set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ]
-dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID
-foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
-
+dg-runtest $run_id_files      "" "-O2 -fgraphite-identity"
+dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
+dg-runtest $block_files       "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
 
 # The default action for the rest of the files is 'compile'.
 set dg-do-what-default compile
-
-# Flags using for other files.
-set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors"
-dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE
+foreach f $scop_files        {lremove wait_to_run_files $f}
+foreach f $id_files          {lremove wait_to_run_files $f}
+foreach f $run_id_files      {lremove wait_to_run_files $f}
+foreach f $interchange_files {lremove wait_to_run_files $f}
+foreach f $block_files       {lremove wait_to_run_files $f}
+dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors"
 
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-0.c b/gcc/testsuite/gcc.dg/graphite/interchange-0.c
index 3e85250..e6e6dfc 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-0.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-0.c
@@ -1,9 +1,16 @@
 /* { dg-require-effective-target size32plus } */
 
-int a[1000][1000];
+#define DEBUG 0
 
-int
-foo (int N)
+#if DEBUG
+#include <stdio.h>
+#endif
+
+#define N 1000
+int a[N][N];
+
+static int __attribute__((noinline))
+foo (void)
 {
   int j;
   int i;
@@ -12,8 +19,27 @@ foo (int N)
     for (j = 0; j < N; j++)
       a[j][i] = a[j][i] + 1;
 
-  return a[N][123];
+  return a[N-1][N-1];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      a[i][j] = 1;
+
+  a[N-1][N-1] = 12;
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 13;
 }
 
-/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ 
-/* { dg-final { cleanup-tree-dump "graphite" } } */
+/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
+/* { dg -final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-1.c b/gcc/testsuite/gcc.dg/graphite/interchange-1.c
index cd9197d..80a2e34 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-1.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-1.c
@@ -2,8 +2,15 @@
 
 /* Formerly known as ltrans-1.c */
 
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 double u[1782225];
-int foo(int N, int *res)
+
+static int __attribute__((noinline))
+foo (int N)
 {
   int i, j;
   double sum = 0.0;
@@ -15,8 +22,27 @@ int foo(int N, int *res)
 
       u[1336 * i] *= 2;
     }
-  *res = sum + N;
+
+  return sum + N + u[1336 * 2] + u[1336];
 }
 
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < 1782225; i++)
+    u[i] = 2;
+
+  res = foo (1335);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 3565793;
+}
+
+
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-10.c b/gcc/testsuite/gcc.dg/graphite/interchange-10.c
index 0cd22a3..17f807b 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-10.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-10.c
@@ -1,5 +1,14 @@
+/* { dg-require-effective-target size32plus } */
+
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 double u[1782225];
-int foo(int N, int *res)
+
+static void __attribute__((noinline))
+foo (int N, int *res)
 {
   int i, j;
   double sum = 0.0;
@@ -12,7 +21,24 @@ int foo(int N, int *res)
     for (j = 0; j < N; j++)
       sum = sum + u[i + 1335 * j];
 
-  *res = sum + N;
+  *res = sum + N + u[1336 * 2] + u[1336];
+}
+
+int
+main (void)
+{
+  int i, res;
+
+  for (i = 0; i < 1782225; i++)
+    u[i] = 2;
+
+  foo (1335, &res);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 7130239;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-11.c b/gcc/testsuite/gcc.dg/graphite/interchange-11.c
index dea8df7..eecc979 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-11.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-11.c
@@ -1,5 +1,14 @@
+/* { dg-require-effective-target size32plus } */
+
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 double u[1782225];
-int foo(int N, int *res)
+
+static void __attribute__((noinline))
+foo (int N, int *res)
 {
   int i, j;
   double sum = 0.0;
@@ -14,5 +23,22 @@ int foo(int N, int *res)
   *res = sum;
 }
 
+int
+main (void)
+{
+  int i, res;
+
+  for (i = 0; i < 1782225; i++)
+    u[i] = 2;
+
+  foo (1335, &res);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 3564450;
+}
+
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
index 73c9c8c..dc5b138 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-12.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
@@ -1,8 +1,16 @@
-#define N 1000
+/* { dg-require-effective-target size32plus } */
 
-float A[N][N], B[N][N], C[N][N];
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
 
-void matmult ()
+#define N 200
+
+int A[N][N], B[N][N], C[N][N];
+
+static int __attribute__((noinline))
+matmult (void)
 {
   int i, j, k;
 
@@ -13,6 +21,30 @@ void matmult ()
         for (k = 0; k < N; k++)
           A[i][j] += B[i][k] * C[k][j];
       }
+
+  return A[0][0] + A[N-1][N-1];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      {
+	A[i][j] = 0;
+	B[i][j] = i - j;
+	C[i][j] = i + j;
+      }
+
+  res = matmult ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 2626800;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-2.c b/gcc/testsuite/gcc.dg/graphite/interchange-2.c
index 6b1dbe6..62692de 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-2.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-2.c
@@ -2,12 +2,19 @@
 
 /* Formerly known as ltrans-2.c */
 
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 double u[1782225];
-int foo(int N, int *res)
+
+static void __attribute__((noinline))
+foo (int N, int *res)
 {
   unsigned int i, j;
   double sum = 0;
-  
+
   /* This loop should be converted to a perfect nest and
      interchanged.  */
   for (i = 0; i < N; i++)
@@ -19,7 +26,25 @@ int foo(int N, int *res)
 	    u[1336 * i] *= 2;
 	}
     }
-  *res = sum + N;
+
+  *res = sum + N + u[1336 * 2] + u[1336];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < 1782225; i++)
+    u[i] = 2;
+
+  foo (1335, &res);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 3565793;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ 
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-3.c b/gcc/testsuite/gcc.dg/graphite/interchange-3.c
index c2a6744..95c228d 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-3.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-3.c
@@ -2,19 +2,44 @@
 
 /* Formerly known as ltrans-3.c */
 
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 double u[1782225];
-int foo(int N, int *res)
+
+static void __attribute__((noinline))
+foo (int N, int *res)
 {
   unsigned int i, j;
   double sum = 0;
-      for (i = 0; i < N; i++)
+  for (i = 0; i < N; i++)
+    {
+      for (j = 0; j < N; j++)
 	{
-	  for (j = 0; j < N; j++)
-	    {
-	      sum = sum + u[i + 1335 * j];
-	    }
+	  sum = sum + u[i + 1335 * j];
 	}
-      *res = sum + N;
+    }
+
+  *res = sum + N + u[1336 * 2] + u[1336];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < 1782225; i++)
+    u[i] = 2;
+
+  foo (1335, &res);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 3565789;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-4.c b/gcc/testsuite/gcc.dg/graphite/interchange-4.c
index c0ec7fa..5d3c7b1 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-4.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-4.c
@@ -2,8 +2,15 @@
 
 /* Formerly known as ltrans-4.c */
 
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 double u[1782225];
-int foo(int N, int *res)
+
+static int __attribute__((noinline))
+foo (int N, int *res)
 {
   int i, j;
   double sum = 0;
@@ -13,7 +20,25 @@ int foo(int N, int *res)
 
   for (i = 0; i < N; i++)
     u[1336 * i] *= 2;
-  *res = sum + N;
+
+  *res = sum + N + u[1336 * 2] + u[1336];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < 1782225; i++)
+    u[i] = 2;
+
+  foo (1335, &res);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 3565793;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-5.c b/gcc/testsuite/gcc.dg/graphite/interchange-5.c
index 19a5e09..a912fe2 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-5.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-5.c
@@ -2,17 +2,44 @@
 
 /* Formerly known as ltrans-5.c */
 
-int foo ()
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
+#define N 100
+#define M 1111
+int A[N][M];
+
+static int __attribute__((noinline))
+foo (void)
 {
-  int A[100][1111];
   int i, j;
 
-  for( i = 0; i < 1111; i++)
-    for( j = 0; j < 100; j++)
+  for( i = 0; i < M; i++)
+    for( j = 0; j < N; j++)
       A[j][i] = 5 * A[j][i];
 
-  return A[10][10];
+  return A[0][0] + A[N-1][M-1];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < M; j++)
+      A[i][j] = 2;
+
+  res = foo ();
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 20;
 }
 
-/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ 
+/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-6.c b/gcc/testsuite/gcc.dg/graphite/interchange-6.c
index 1845487..2ff886c 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-6.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-6.c
@@ -2,17 +2,44 @@
 
 /* Formerly known as ltrans-6.c */
 
-int medium_loop_interchange(int A[100][200])
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
+#define N 100
+#define M 200
+
+static int __attribute__((noinline))
+foo (int A[N][M])
 {
-  int i,j;
+  int i, j;
 
   /* This loop should be interchanged. */
-
-  for(j = 0; j < 200; j++)
-    for(i = 0; i < 100; i++)
+  for(j = 0; j < M; j++)
+    for(i = 0; i < N; i++)
       A[i][j] = A[i][j] + A[i][j];
 
-  return A[1][1];
+  return A[0][0] + A[N-1][M-1];
+}
+
+int
+main (void)
+{
+  int A[N][M];
+  int i, j, res;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < M; j++)
+      A[i][j] = 2;
+
+  res = foo (A);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 8;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-7.c b/gcc/testsuite/gcc.dg/graphite/interchange-7.c
index 2a7bf86..a030943 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-7.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-7.c
@@ -1,17 +1,45 @@
+/* { dg-require-effective-target size32plus } */
+
 /* Formerly known as ltrans-8.c */
 
-double
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
+#define N 111
+#define M 1111
+
+static int __attribute__((noinline))
 foo (double *a)
 {
   int i,j;
-  double r = 0.0;
+  int r = 0;
 
-  for (i = 0; i < 100; ++i)
-    for (j = 0; j < 1000; ++j)
-      r += a[j * 100 + i];
+  for (i = 0; i < N; ++i)
+    for (j = 0; j < M; ++j)
+      r += a[j * N + i];
 
   return r;
 }
 
+int
+main (void)
+{
+  double A[N*M];
+  int i, res;
+
+  for (i = 0; i < N*M; i++)
+    A[i] = 2;
+
+  res = foo (A);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 246642;
+}
+
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-8.c b/gcc/testsuite/gcc.dg/graphite/interchange-8.c
index 24b9a15..94bd66b 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-8.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-8.c
@@ -1,9 +1,15 @@
-int
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
+int B[4];
+int A[4][4][4][4];
+
+static int __attribute__((noinline))
 foo (void)
 {
   int i, j, k, l;
-  int B[4];
-  int A[4][4][4][4];
 
   for (l = 0; l < 4; l++)
     {
@@ -37,7 +43,36 @@ foo (void)
 	}
     }
 
-  return A[0][1][0][2];
+  return A[0][1][0][2] + A[0][3][0][3] + A[0][2][0][2] + A[0][1][0][1] + A[3][3][0][2];
+}
+
+int
+main (void)
+{
+  int i, j, k, l, res;
+
+  for (i = 0; i < 4; i++)
+    B[i] = 2;
+
+  for (i = 0; i < 4; i++)
+    for (j = 0; j < 4; j++)
+      for (k = 0; k < 4; k++)
+	for (l = 0; l < 4; l++)
+	  A[i][j][k][l] = i + j + k + l;
+
+  res = foo ();
+
+#if DEBUG
+  for (i = 0; i < 4; i++)
+    for (j = 0; j < 4; j++)
+      for (k = 0; k < 4; k++)
+	for (l = 0; l < 4; l++)
+	  fprintf (stderr, "A[%d][%d][%d][%d] = %d \n", i, j, k, l, A[i][j][k][l]);
+
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 424;
 }
 
 /* Loops K and L should be interchanged.  */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-9.c b/gcc/testsuite/gcc.dg/graphite/interchange-9.c
index e55d818..d4e05c3 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-9.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-9.c
@@ -1,15 +1,43 @@
-int
+/* { dg-require-effective-target size32plus } */
+
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
+#define N 1111
+#define M 1111
+
+static int __attribute__((noinline))
 foo (int *x)
 {
   int i, j;
   int sum = 0;
 
-  for (j = 0;  j < 10000; ++j)
-    for (i = 0;  i < 10000; ++i)
-      sum += x[10000 * i + j];
+  for (j = 0; j < M; ++j)
+    for (i = 0;  i < N; ++i)
+      sum += x[M * i + j];
 
   return sum;
 }
 
+int
+main (void)
+{
+  int A[N*M];
+  int i, res;
+
+  for (i = 0; i < N*M; i++)
+    A[i] = 2;
+
+  res = foo (A);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 2468642;
+}
+
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
index 915a7ac..1e44f0a 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
@@ -1,22 +1,55 @@
+/* { dg-require-effective-target size32plus } */
+
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
 #define NMAX 2000
 
-static double x1[NMAX], x2[NMAX], a[NMAX][NMAX], y_1[NMAX], y_2[NMAX];
+static int x1[NMAX], x2[NMAX], a[NMAX][NMAX], y1[NMAX], y2[NMAX];
 
-void mvt(long N) {
+static int __attribute__((noinline))
+mvt (long N)
+{
 
-    int i,j;
+  int i,j;
 
-    for (i=0; i<N; i++) {
-        for (j=0; j<N; j++) {
-            x1[i] = x1[i] + a[i][j] * y_1[j];
-        }
-    }
-    
-    for (i=0; i<N; i++) {
-        for (j=0; j<N; j++) {
-            x2[i] = x2[i] + a[j][i] * y_2[j];
-        }
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      x1[i] = x1[i] + a[i][j] * y1[j];
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      x2[i] = x2[i] + a[j][i] * y2[j];
+
+  return x1[0] + x2[0];
+}
+
+int
+main (void)
+{
+  int i, j, res;
+
+  for (i = 0; i < NMAX; i++)
+    for (j = 0; j < NMAX; j++)
+      a[i][j] = i + j;
+
+  for (i = 0; i < NMAX; i++)
+    {
+      x1[i] = 0;
+      x2[i] = 2*i;
+      y1[i] = 100 - i;
+      y2[i] = i;
     }
+
+  res = mvt (NMAX);
+
+#if DEBUG
+  fprintf (stderr, "res = %d \n", res);
+#endif
+
+  return res != 199900000;
 }
 
 /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ 
diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-2.c b/gcc/testsuite/gcc.dg/graphite/run-id-2.c
index acaa14c..0fd5efd 100644
--- a/gcc/testsuite/gcc.dg/graphite/run-id-2.c
+++ b/gcc/testsuite/gcc.dg/graphite/run-id-2.c
@@ -1,6 +1,7 @@
 int a[1] = {1};
 
-static int __attribute__((noinline)) foo(int n)
+static int __attribute__((noinline))
+foo(int n)
 {
   int i, c = 0;
   for (i = 0; i < n; i++)
@@ -24,5 +25,3 @@ int main()
    foo(0) != 0 || foo(1) != 1 || bar(0) != 0 || bar(1) != 2 || bar(2) != 5;
 }
 
-/* { dg-do run  } */
-/* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gfortran.dg/graphite/graphite.exp b/gcc/testsuite/gfortran.dg/graphite/graphite.exp
index 99b46de..11dd42d 100644
--- a/gcc/testsuite/gfortran.dg/graphite/graphite.exp
+++ b/gcc/testsuite/gfortran.dg/graphite/graphite.exp
@@ -33,56 +33,36 @@ proc lremove {list_variable value} {
 # The default action for a test is 'compile'.  Save current default.
 global dg-do-what-default
 set save-dg-do-what-default ${dg-do-what-default}
-set dg-do-what-default compile
 
 # Initialize `dg'.
 dg-init
 
-# Main loop.
 set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ]
-
-# Flags using for block-* files.
-set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
- -fno-loop-interchange -fdump-tree-graphite-all"
-set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.\[fF\]{,90,95,03,08} ] ]
-gfortran-dg-runtest $block_files $DEFAULT_FLAGS_GRAPHITE_BLOCK
-foreach block_file $block_files {lremove wait_to_run_files $block_file}
-
-# Flags using for id-* files.
-set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
-set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.\[fF\]{,90,95,03,08} ] ]
-gfortran-dg-runtest $id_files $DEFAULT_FLAGS_GRAPHITE_IDENTITY
-foreach id_file $id_files {lremove wait_to_run_files $id_file}
-
-# Flags using for interchange-* files.
-set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
- -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
+set block_files       [lsort [glob -nocomplain $srcdir/$subdir/block-*.\[fF\]{,90,95,03,08} ] ]
+set id_files          [lsort [glob -nocomplain $srcdir/$subdir/id-*.\[fF\]{,90,95,03,08} ] ]
 set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.\[fF\]{,90,95,03,08} ] ]
-gfortran-dg-runtest $interchange_files $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE
-foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
-
-# Flags using for scop-* files.
-set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
 set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.\[fF\]{,90,95,03,08} ] ]
-gfortran-dg-runtest $scop_files $DEFAULT_FLAGS_GRAPHITE_SCOP
-foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
-
-# Schedule now the tests to be run.
-set dg-do-what-default run
-
-# Flags using for run-id-* files.
-set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity"
 set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.\[fF\]{,90,95,03,08} ] ]
-gfortran-dg-runtest $run_id_files $DEFAULT_FLAGS_RUN_ID
-foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
 
+# Tests to be compiled.
+set dg-do-what-default compile
+gfortran-dg-runtest $scop_files        "-O2 -fgraphite -fdump-tree-graphite-all"
+gfortran-dg-runtest $id_files          "-O2 -fgraphite-identity -ffast-math"
+gfortran-dg-runtest $interchange_files "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
+gfortran-dg-runtest $block_files       "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
+
+# Tests to be run.
+set dg-do-what-default run
+gfortran-dg-runtest $run_id_files      "-O2 -fgraphite-identity"
 
 # The default action for the rest of the files is 'compile'.
 set dg-do-what-default compile
-
-# Flags using for other files.
-set DEFAULT_GRAPHITE_FLAGS ""
-gfortran-dg-runtest $wait_to_run_files $DEFAULT_GRAPHITE_FLAGS
+foreach f $block_files       {lremove wait_to_run_files $f}
+foreach f $id_files          {lremove wait_to_run_files $f}
+foreach f $interchange_files {lremove wait_to_run_files $f}
+foreach f $scop_files        {lremove wait_to_run_files $f}
+foreach f $run_id_files      {lremove wait_to_run_files $f}
+gfortran-dg-runtest $wait_to_run_files ""
 
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
-- 
1.6.3.3

>From 8745a4fd77636af5fbbfece8b9561f87b33576cc Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Feb 2010 19:23:16 +0000
Subject: [PATCH 10/13] Correct the lexicographical function, add debug_pddr.

2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (new_poly_ddr): Initialize PDDR_KIND and
	PDDR_ORIGINAL_SCATTERING_P.
	(pddr_is_empty): Rewritten.
	(print_dependence_polyhedron_layout): New.
	(print_pddr): New.
	(debug_pddr): New.
	(build_alias_set_powerset): Moved up.
	(poly_drs_may_alias_p): Moved up.
	(lexicographically_gt_p): Removed.
	(build_lexicographically_gt_constraint): Renamed
	build_lexicographical_constraint, reimplemented.
	(dependence_polyhedron_1): Simplified parameters.
	(dependence_polyhedron): Same.  Keep along empty PDDRs
	to make efficient use of the cache.
	(reduction_dr_p): Compute the PBBs don't pass them as parameters.
	(graphite_legal_transform_dr): Rewritten.
	(graphite_legal_transform_bb): Pass fewer arguments to
	graphite_legal_transform_dr.
	(graphite_carried_dependence_level_k): Simplified implementation.
	(dot_original_deps_stmt_1): Call dependence_polyhedron.
	(dot_transformed_deps_stmt_1): Same.
	(dot_original_deps): Same.
	(dot_transformed_deps): Same.
	* graphite-dependences.h (struct poly_ddr): Added a new field
	original_scattering_p.
	(PDDR_ORIGINAL_SCATTERING_P): New.
	(print_pddr): Declared.
	(debug_pddr): Declared.
	* graphite-ppl.c: Clarify comment.
	* sese.h (print_gimple_bb): Removed unused declaration.
	(debug_gbb): Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156474 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite     |   34 +++
 gcc/graphite-dependences.c |  580 +++++++++++++++++++++++---------------------
 gcc/graphite-dependences.h |    8 +
 gcc/graphite-ppl.c         |    2 +-
 gcc/sese.h                 |    3 -
 5 files changed, 347 insertions(+), 280 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index fe9962c..c5d0efe 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,39 @@
 2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-dependences.c (new_poly_ddr): Initialize PDDR_KIND and
+	PDDR_ORIGINAL_SCATTERING_P.
+	(pddr_is_empty): Rewritten.
+	(print_dependence_polyhedron_layout): New.
+	(print_pddr): New.
+	(debug_pddr): New.
+	(build_alias_set_powerset): Moved up.
+	(poly_drs_may_alias_p): Moved up.
+	(lexicographically_gt_p): Removed.
+	(build_lexicographically_gt_constraint): Renamed
+	build_lexicographical_constraint, reimplemented.
+	(dependence_polyhedron_1): Simplified parameters.
+	(dependence_polyhedron): Same.  Keep along empty PDDRs
+	to make efficient use of the cache.
+	(reduction_dr_p): Compute the PBBs don't pass them as parameters.
+	(graphite_legal_transform_dr): Rewritten.
+	(graphite_legal_transform_bb): Pass fewer arguments to
+	graphite_legal_transform_dr.
+	(graphite_carried_dependence_level_k): Simplified implementation.
+	(dot_original_deps_stmt_1): Call dependence_polyhedron.
+	(dot_transformed_deps_stmt_1): Same.
+	(dot_original_deps): Same.
+	(dot_transformed_deps): Same.
+	* graphite-dependences.h (struct poly_ddr): Added a new field
+	original_scattering_p.
+	(PDDR_ORIGINAL_SCATTERING_P): New.
+	(print_pddr): Declared.
+	(debug_pddr): Declared.
+	* graphite-ppl.c: Clarify comment.
+	* sese.h (print_gimple_bb): Removed unused declaration.
+	(debug_gbb): Same.
+
+2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* testsuite/g++.dg/graphite/graphite.exp: Rewritten.
 	* testsuite/gcc.dg/graphite/graphite.exp: Rewritten.
 	* testsuite/gfortran.dg/graphite/graphite.exp: Rewritten.
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 7b462f7..a6a7e57 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -51,20 +51,26 @@ along with GCC; see the file COPYING3.  If not see
 #include "graphite-dependences.h"
 
 /* Returns a new polyhedral Data Dependence Relation (DDR).  SOURCE is
-   the source data reference, SINK is the sink data reference.  SOURCE
-   and SINK define an edge in the Data Dependence Graph (DDG).  */
+   the source data reference, SINK is the sink data reference.  When
+   the Data Dependence Polyhedron DDP is not NULL or not empty, SOURCE
+   and SINK are in dependence as described by DDP.  */
 
 static poly_ddr_p
 new_poly_ddr (poly_dr_p source, poly_dr_p sink,
-	      ppl_Pointset_Powerset_C_Polyhedron_t ddp)
+	      ppl_Pointset_Powerset_C_Polyhedron_t ddp,
+	      bool original_scattering_p)
 {
-  poly_ddr_p pddr;
+  poly_ddr_p pddr = XNEW (struct poly_ddr);
 
-  pddr = XNEW (struct poly_ddr);
   PDDR_SOURCE (pddr) = source;
   PDDR_SINK (pddr) = sink;
   PDDR_DDP (pddr) = ddp;
-  PDDR_KIND (pddr) = unknown_dependence;
+  PDDR_ORIGINAL_SCATTERING_P (pddr) = original_scattering_p;
+
+  if (!ddp || ppl_Pointset_Powerset_C_Polyhedron_is_empty (ddp))
+    PDDR_KIND (pddr) = no_dependence;
+  else
+    PDDR_KIND (pddr) = has_dependence;
 
   return pddr;
 }
@@ -106,17 +112,161 @@ hash_poly_ddr_p (const void *pddr)
 static bool
 pddr_is_empty (poly_ddr_p pddr)
 {
-  if (PDDR_KIND (pddr) != unknown_dependence)
-    return PDDR_KIND (pddr) == no_dependence ? true : false;
+  if (!pddr)
+    return true;
+
+  gcc_assert (PDDR_KIND (pddr) != unknown_dependence);
+
+  return PDDR_KIND (pddr) == no_dependence ? true : false;
+}
+
+/* Prints to FILE the layout of the dependence polyhedron of PDDR:
+
+   T1|I1|T2|I2|S1|S2|G
+
+   with
+   | T1 and T2 the scattering dimensions for PDDR_SOURCE and PDDR_SINK
+   | I1 and I2 the iteration domains
+   | S1 and S2 the subscripts
+   | G the global parameters.  */
+
+static void
+print_dependence_polyhedron_layout (FILE *file, poly_ddr_p pddr)
+{
+  poly_dr_p pdr1 = PDDR_SOURCE (pddr);
+  poly_dr_p pdr2 = PDDR_SINK (pddr);
+  poly_bb_p pbb1 = PDR_PBB (pdr1);
+  poly_bb_p pbb2 = PDR_PBB (pdr2);
+
+  graphite_dim_t i;
+  graphite_dim_t tdim1 = PDDR_ORIGINAL_SCATTERING_P (pddr) ?
+    pbb_nb_scattering_orig (pbb1) : pbb_nb_scattering_transform (pbb1);
+  graphite_dim_t tdim2 = PDDR_ORIGINAL_SCATTERING_P (pddr) ?
+    pbb_nb_scattering_orig (pbb2) : pbb_nb_scattering_transform (pbb2);
+  graphite_dim_t idim1 = pbb_dim_iter_domain (pbb1);
+  graphite_dim_t idim2 = pbb_dim_iter_domain (pbb2);
+  graphite_dim_t sdim1 = PDR_NB_SUBSCRIPTS (pdr1) + 1;
+  graphite_dim_t sdim2 = PDR_NB_SUBSCRIPTS (pdr2) + 1;
+  graphite_dim_t gdim = scop_nb_params (PBB_SCOP (pbb1));
+
+  fprintf (file, "#  eq");
+
+  for (i = 0; i < tdim1; i++)
+    fprintf (file, "   t1_%d", (int) i);
+  for (i = 0; i < idim1; i++)
+    fprintf (file, "   i1_%d", (int) i);
+  for (i = 0; i < tdim2; i++)
+    fprintf (file, "   t2_%d", (int) i);
+  for (i = 0; i < idim2; i++)
+    fprintf (file, "   i2_%d", (int) i);
+  for (i = 0; i < sdim1; i++)
+    fprintf (file, "   s1_%d", (int) i);
+  for (i = 0; i < sdim2; i++)
+    fprintf (file, "   s2_%d", (int) i);
+  for (i = 0; i < gdim; i++)
+    fprintf (file, "    g_%d", (int) i);
+
+  fprintf (file, "    cst\n");
+}
+
+/* Prints to FILE the poly_ddr_p PDDR.  */
+
+void
+print_pddr (FILE *file, poly_ddr_p pddr)
+{
+  fprintf (file, "pddr (kind: ");
+
+  if (PDDR_KIND (pddr) == unknown_dependence)
+    fprintf (file, "unknown_dependence");
+  else if (PDDR_KIND (pddr) == no_dependence)
+    fprintf (file, "no_dependence");
+  else if (PDDR_KIND (pddr) == has_dependence)
+    fprintf (file, "has_dependence");
 
-  if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (PDDR_DDP (pddr)))
+  fprintf (file, "\n  source ");
+  print_pdr (file, PDDR_SOURCE (pddr));
+
+  fprintf (file, "\n  sink ");
+  print_pdr (file, PDDR_SINK (pddr));
+
+  if (PDDR_KIND (pddr) == has_dependence)
     {
-      PDDR_KIND (pddr) = no_dependence;
-      return true;
+      fprintf (file, "\n  dependence polyhedron (\n");
+      print_dependence_polyhedron_layout (file, pddr);
+      ppl_print_powerset_matrix (file, PDDR_DDP (pddr));
+      fprintf (file, ")\n");
     }
 
-  PDDR_KIND (pddr) = has_dependence;
-  return false;
+  fprintf (file, ")\n");
+}
+
+/* Prints to STDERR the poly_ddr_p PDDR.  */
+
+void
+debug_pddr (poly_ddr_p pddr)
+{
+  print_pddr (stderr, pddr);
+}
+
+
+/* Remove all the dimensions except alias information at dimension
+   ALIAS_DIM.  */
+
+static void
+build_alias_set_powerset (ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset,
+			  ppl_dimension_type alias_dim)
+{
+  ppl_dimension_type *ds;
+  ppl_dimension_type access_dim;
+  unsigned i, pos = 0;
+
+  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (alias_powerset,
+						      &access_dim);
+  ds = XNEWVEC (ppl_dimension_type, access_dim-1);
+  for (i = 0; i < access_dim; i++)
+    {
+      if (i == alias_dim)
+	continue;
+
+      ds[pos] = i;
+      pos++;
+    }
+
+  ppl_Pointset_Powerset_C_Polyhedron_remove_space_dimensions (alias_powerset,
+							      ds,
+							      access_dim - 1);
+  free (ds);
+}
+
+/* Return true when PDR1 and PDR2 may alias.  */
+
+static bool
+poly_drs_may_alias_p (poly_dr_p pdr1, poly_dr_p pdr2)
+{
+  ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset1, alias_powerset2;
+  ppl_Pointset_Powerset_C_Polyhedron_t accesses1 = PDR_ACCESSES (pdr1);
+  ppl_Pointset_Powerset_C_Polyhedron_t accesses2 = PDR_ACCESSES (pdr2);
+  ppl_dimension_type alias_dim1 = pdr_alias_set_dim (pdr1);
+  ppl_dimension_type alias_dim2 = pdr_alias_set_dim (pdr2);
+  int empty_p;
+
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
+    (&alias_powerset1, accesses1);
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
+    (&alias_powerset2, accesses2);
+
+  build_alias_set_powerset (alias_powerset1, alias_dim1);
+  build_alias_set_powerset (alias_powerset2, alias_dim2);
+
+  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign
+    (alias_powerset1, alias_powerset2);
+
+  empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (alias_powerset1);
+
+  ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset1);
+  ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset2);
+
+  return !empty_p;
 }
 
 /* Returns a polyhedron of dimension DIM.
@@ -262,33 +412,6 @@ build_pairwise_scheduling (graphite_dim_t dim,
   return res;
 }
 
-/* Returns true when adding to the RES dependence polyhedron the
-   lexicographical constraint: "DIM compared to DIM + OFFSET" returns
-   an empty polyhedron.  The comparison depends on DIRECTION as: if
-   DIRECTION is equal to -1, the first dimension DIM to be compared
-   comes before the second dimension DIM + OFFSET, equal to 0 when DIM
-   and DIM + OFFSET are equal, and DIRECTION is set to 1 when DIM
-   comes after DIM + OFFSET.  */
-
-static bool
-lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res,
-			graphite_dim_t dim,
-			graphite_dim_t offset,
-			int direction, graphite_dim_t i)
-{
-  ppl_Pointset_Powerset_C_Polyhedron_t ineq;
-  bool empty_p;
-
-  ineq = build_pairwise_scheduling (dim, i, offset, direction);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (ineq, res);
-  empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (ineq);
-  if (!empty_p)
-    ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, ineq);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (ineq);
-
-  return !empty_p;
-}
-
 /* Add to a non empty polyhedron RES the precedence constraints for
    the lexicographical comparison of time vectors in RES following the
    lexicographical order.  DIM is the dimension of the polyhedron RES.
@@ -302,36 +425,45 @@ lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res,
    PDR2 to PDR1.  */
 
 static void
-build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res,
-				       graphite_dim_t dim,
-				       graphite_dim_t tdim,
-				       graphite_dim_t offset,
-				       int direction)
+build_lexicographical_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res,
+				  graphite_dim_t dim,
+				  graphite_dim_t tdim,
+				  graphite_dim_t offset,
+				  int direction)
 {
   graphite_dim_t i;
 
-  if (lexicographically_gt_p (*res, dim, offset, direction, 0))
-    return;
-
-  for (i = 0; i < tdim - 1; i++)
+  for (i = 0; i < tdim - 1; i+=2)
     {
-      ppl_Pointset_Powerset_C_Polyhedron_t sceq;
+      ppl_Pointset_Powerset_C_Polyhedron_t ineq;
+      bool empty_p;
 
-      /* All the dimensions up to I are equal, ...  */
-      sceq = build_pairwise_scheduling (dim, i, offset, 0);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, sceq);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (sceq);
+      /* Identify the static schedule dimensions.  */
+      ineq = build_pairwise_scheduling (dim, i, offset, 0);
+      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (ineq, *res);
+      empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (ineq);
 
-      /* ... and at depth I+1 they are not equal anymore.  */
-      if (lexicographically_gt_p (*res, dim, offset, direction, i + 1))
-	return;
-    }
+      if (empty_p)
+	{
+	  /* Add the lexicographical dynamic schedule dimension.  */
+	  if (i > 0)
+	    ineq = build_pairwise_scheduling (dim, i - 1, offset, direction);
 
-  if (i == tdim - 1)
-    {
-      ppl_delete_Pointset_Powerset_C_Polyhedron (*res);
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (res, dim, 1);
+	  return;
+	}
+
+      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, ineq);
+      ppl_delete_Pointset_Powerset_C_Polyhedron (ineq);
+
+      /* Identify the dynamic schedule dimensions.  */
+      ineq = build_pairwise_scheduling (dim, i + 1, offset, 0);
+      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, ineq);
+      ppl_delete_Pointset_Powerset_C_Polyhedron (ineq);
     }
+
+  /* There is no dependence.  */
+  ppl_delete_Pointset_Powerset_C_Polyhedron (*res);
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (res, dim, 1);
 }
 
 /* Build the dependence polyhedron for data references PDR1 and PDR2.
@@ -345,31 +477,27 @@ build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res
    | S1 and S2 the subscripts
    | G the global parameters.
 
-   D1 and D2 are the iteration domains of PDR1 and PDR2.
-
-   SCAT1 and SCAT2 are the scattering polyhedra for PDR1 and PDR2.
-   When ORIGINAL_SCATTERING_P is true, then the scattering polyhedra
-   SCAT1 and SCAT2 correspond to the original scattering of the
-   program, otherwise they correspond to the transformed scattering.
-
    When DIRECTION is set to 1, compute the direct dependence from PDR1
    to PDR2, and when DIRECTION is -1, compute the reversed dependence
    relation, from PDR2 to PDR1.  */
 
-static poly_ddr_p
-dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
-		         ppl_Pointset_Powerset_C_Polyhedron_t d1,
-		         ppl_Pointset_Powerset_C_Polyhedron_t d2,
-		         poly_dr_p pdr1, poly_dr_p pdr2,
-	                 ppl_Polyhedron_t scat1, ppl_Polyhedron_t scat2,
-		         int direction,
-		         bool original_scattering_p)
+static ppl_Pointset_Powerset_C_Polyhedron_t
+dependence_polyhedron_1 (poly_dr_p pdr1, poly_dr_p pdr2,
+		         int direction, bool original_scattering_p)
 {
+  poly_bb_p pbb1 = PDR_PBB (pdr1);
+  poly_bb_p pbb2 = PDR_PBB (pdr2);
   scop_p scop = PBB_SCOP (pbb1);
+  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
+  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
   graphite_dim_t tdim1 = original_scattering_p ?
     pbb_nb_scattering_orig (pbb1) : pbb_nb_scattering_transform (pbb1);
   graphite_dim_t tdim2 = original_scattering_p ?
     pbb_nb_scattering_orig (pbb2) : pbb_nb_scattering_transform (pbb2);
+  ppl_Polyhedron_t scat1 = original_scattering_p ?
+    PBB_ORIGINAL_SCATTERING (pbb1) : PBB_TRANSFORMED_SCATTERING (pbb1);
+  ppl_Polyhedron_t scat2 = original_scattering_p ?
+    PBB_ORIGINAL_SCATTERING (pbb2) : PBB_TRANSFORMED_SCATTERING (pbb2);
   graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
   graphite_dim_t ddim2 = pbb_dim_iter_domain (pbb2);
   graphite_dim_t sdim1 = PDR_NB_SUBSCRIPTS (pdr1) + 1;
@@ -425,53 +553,52 @@ dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
   ppl_delete_Pointset_Powerset_C_Polyhedron (dreq);
 
   if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (res))
-    build_lexicographically_gt_constraint (&res, dim, MIN (tdim1, tdim2),
-					   tdim1 + ddim1, direction);
+    build_lexicographical_constraint (&res, dim, MIN (tdim1, tdim2),
+				      tdim1 + ddim1, direction);
 
-  return new_poly_ddr (pdr1, pdr2, res);
+  return res;
 }
 
 /* Build the dependence polyhedron for data references PDR1 and PDR2.
    If possible use already cached information.
 
-   D1 and D2 are the iteration domains of PDR1 and PDR2.
-
-   SCAT1 and SCAT2 are the scattering polyhedra for PDR1 and PDR2.
-   When ORIGINAL_SCATTERING_P is true, then the scattering polyhedra
-   SCAT1 and SCAT2 correspond to the original scattering of the
-   program, otherwise they correspond to the transformed scattering.
-
    When DIRECTION is set to 1, compute the direct dependence from PDR1
    to PDR2, and when DIRECTION is -1, compute the reversed dependence
    relation, from PDR2 to PDR1.  */
 
 static poly_ddr_p
-dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
-		       ppl_Pointset_Powerset_C_Polyhedron_t d1,
-		       ppl_Pointset_Powerset_C_Polyhedron_t d2,
-		       poly_dr_p pdr1, poly_dr_p pdr2,
-	               ppl_Polyhedron_t scat1, ppl_Polyhedron_t scat2,
-		       int direction,
-		       bool original_scattering_p)
+dependence_polyhedron (poly_dr_p pdr1, poly_dr_p pdr2,
+		       int direction, bool original_scattering_p)
 {
   PTR *x = NULL;
   poly_ddr_p res;
+  ppl_Pointset_Powerset_C_Polyhedron_t ddp;
 
+  /* Return the PDDR from the cache if it already has been computed.  */
   if (original_scattering_p)
     {
       struct poly_ddr tmp;
+      scop_p scop = PBB_SCOP (PDR_PBB (pdr1));
 
       tmp.source = pdr1;
       tmp.sink = pdr2;
-      x = htab_find_slot (SCOP_ORIGINAL_PDDRS (PBB_SCOP (pbb1)),
+      x = htab_find_slot (SCOP_ORIGINAL_PDDRS (scop),
                           &tmp, INSERT);
 
       if (x && *x)
 	return (poly_ddr_p) *x;
     }
 
-  res = dependence_polyhedron_1 (pbb1, pbb2, d1, d2, pdr1, pdr2,
-                                 scat1, scat2, direction, original_scattering_p);
+  if ((pdr_read_p (pdr1) && pdr_read_p (pdr2))
+      || PDR_BASE_OBJECT_SET (pdr1) != PDR_BASE_OBJECT_SET (pdr2)
+      || PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2)
+      || !poly_drs_may_alias_p (pdr1, pdr2))
+    ddp = NULL;
+  else
+    ddp = dependence_polyhedron_1 (pdr1, pdr2, direction,
+				   original_scattering_p);
+
+  res = new_poly_ddr (pdr1, pdr2, ddp, original_scattering_p);
 
   if (original_scattering_p)
     *x = res;
@@ -479,40 +606,6 @@ dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
   return res;
 }
 
-/* Returns the Polyhedral Data Dependence Relation (PDDR) between PDR1
-   contained in PBB1 and PDR2 contained in PBB2.  When
-   ORIGINAL_SCATTERING_P is true, return the PDDR corresponding to the
-   original scattering, or NULL if the dependence relation is empty.
-   When ORIGINAL_SCATTERING_P is false, return the PDDR corresponding
-   to the transformed scattering.  When DIRECTION is set to 1, compute
-   the direct dependence from PDR1 to PDR2, and when DIRECTION is -1,
-   compute the reversed dependence relation, from PDR2 to PDR1.  */
-
-static poly_ddr_p
-build_pddr (poly_bb_p pbb1, poly_bb_p pbb2, poly_dr_p pdr1, poly_dr_p pdr2,
-	    int direction, bool original_scattering_p)
-{
-  poly_ddr_p pddr;
-  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
-  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
-  ppl_Polyhedron_t scat1 = original_scattering_p ?
-    PBB_ORIGINAL_SCATTERING (pbb1) : PBB_TRANSFORMED_SCATTERING (pbb1);
-  ppl_Polyhedron_t scat2 = original_scattering_p ?
-    PBB_ORIGINAL_SCATTERING (pbb2) : PBB_TRANSFORMED_SCATTERING (pbb2);
-
-  if ((pdr_read_p (pdr1) && pdr_read_p (pdr2))
-      || PDR_BASE_OBJECT_SET (pdr1) != PDR_BASE_OBJECT_SET (pdr2)
-      || PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2))
-    return NULL;
-
-  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, scat1, scat2,
-				direction, original_scattering_p);
-  if (pddr_is_empty (pddr))
-    return NULL;
-
-  return pddr;
-}
-
 /* Return true when the data dependence relation between the data
    references PDR1 belonging to PBB1 and PDR2 is part of a
    reduction.  */
@@ -535,9 +628,11 @@ reduction_dr_1 (poly_bb_p pbb1, poly_dr_p pdr1, poly_dr_p pdr2)
    part of a reduction.  */
 
 static inline bool
-reduction_dr_p (poly_bb_p pbb1, poly_bb_p pbb2,
-		poly_dr_p pdr1, poly_dr_p pdr2)
+reduction_dr_p (poly_dr_p pdr1, poly_dr_p pdr2)
 {
+  poly_bb_p pbb1 = PDR_PBB (pdr1);
+  poly_bb_p pbb2 = PDR_PBB (pdr2);
+
   if (PBB_IS_REDUCTION (pbb1))
     return reduction_dr_1 (pbb1, pdr1, pdr2);
 
@@ -552,70 +647,71 @@ reduction_dr_p (poly_bb_p pbb1, poly_bb_p pbb2,
    functions.  */
 
 static bool
-graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
-			     poly_dr_p pdr1, poly_dr_p pdr2)
+graphite_legal_transform_dr (poly_dr_p pdr1, poly_dr_p pdr2)
 {
-  ppl_Polyhedron_t st1, st2;
   ppl_Pointset_Powerset_C_Polyhedron_t po, pt;
   graphite_dim_t ddim1, otdim1, otdim2, ttdim1, ttdim2;
-  ppl_Pointset_Powerset_C_Polyhedron_t temp;
+  ppl_Pointset_Powerset_C_Polyhedron_t po_temp;
   ppl_dimension_type pdim;
   bool is_empty_p;
-  poly_ddr_p pddr;
+  poly_ddr_p opddr, tpddr;
+  poly_bb_p pbb1, pbb2;
 
-  if (reduction_dr_p (pbb1, pbb2, pdr1, pdr2))
+  if (reduction_dr_p (pdr1, pdr2))
     return true;
 
-  pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, 1, true);
-  if (!pddr)
+  /* We build the reverse dependence relation for the transformed
+     scattering, such that when we intersect it with the original PO,
+     we get an empty intersection when the transform is legal:
+     i.e. the transform should reverse no dependences, and so PT, the
+     reversed transformed PDDR, should have no constraint from PO.  */
+  opddr = dependence_polyhedron (pdr1, pdr2, 1, true);
+  tpddr = dependence_polyhedron (pdr1, pdr2, -1, false);
+
     /* There are no dependences between PDR1 and PDR2 in the original
-       version of the program, so the transform is legal.  */
+       version of the program, or after the transform, so the
+       transform is legal.  */
+  if (pddr_is_empty (opddr))
     return true;
 
-  po = PDDR_DDP (pddr);
+  if (pddr_is_empty (tpddr))
+    {
+      free_poly_ddr (tpddr);
+      return true;
+    }
 
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "\nloop carries dependency.\n");
+  po = PDDR_DDP (opddr);
+  pt = PDDR_DDP (tpddr);
 
-  st1 = PBB_TRANSFORMED_SCATTERING (pbb1);
-  st2 = PBB_TRANSFORMED_SCATTERING (pbb2);
+  /* Copy PO into PO_TEMP, such that PO is not destroyed.  PO is
+     stored in a cache and should not be modified or freed.  */
+  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &pdim);
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&po_temp,
+							       pdim, 0);
+  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (po_temp, po);
+
+  /* Extend PO and PT to have the same dimensions.  */
+  pbb1 = PDR_PBB (pdr1);
+  pbb2 = PDR_PBB (pdr2);
   ddim1 = pbb_dim_iter_domain (pbb1);
   otdim1 = pbb_nb_scattering_orig (pbb1);
   otdim2 = pbb_nb_scattering_orig (pbb2);
   ttdim1 = pbb_nb_scattering_transform (pbb1);
   ttdim2 = pbb_nb_scattering_transform (pbb2);
-
-  /* Copy the PO polyhedron into the TEMP, so it is not destroyed.
-     Keep in mind, that PO polyhedron might be restored from the cache
-     and should not be modified!  */
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &pdim);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&temp, pdim, 0);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (temp, po);
-
-  /* We build the reverse dependence relation for the transformed
-     scattering, such that when we intersect it with the original PO,
-     we get an empty intersection when the transform is legal:
-     i.e. the transform should reverse no dependences, and so PT, the
-     reversed transformed PDDR, should have no constraint from PO.  */
-  pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, -1, false);
-  if (!pddr)
-    /* There are no dependences after the transform, so the transform
-       is legal.  */
-    return true;
-
-  pt = PDDR_DDP (pddr);
-
-  /* Extend PO and PT to have the same dimensions.  */
-  ppl_insert_dimensions_pointset (temp, otdim1, ttdim1);
-  ppl_insert_dimensions_pointset (temp, otdim1 + ttdim1 + ddim1 + otdim2, ttdim2);
+  ppl_insert_dimensions_pointset (po_temp, otdim1, ttdim1);
+  ppl_insert_dimensions_pointset (po_temp, otdim1 + ttdim1 + ddim1 + otdim2,
+				  ttdim2);
   ppl_insert_dimensions_pointset (pt, 0, otdim1);
   ppl_insert_dimensions_pointset (pt, otdim1 + ttdim1 + ddim1, otdim2);
 
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (temp, pt);
-  is_empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (temp);
+  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (po_temp, pt);
+  is_empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (po_temp);
 
-  ppl_delete_Pointset_Powerset_C_Polyhedron (temp);
-  free_poly_ddr (pddr);
+  ppl_delete_Pointset_Powerset_C_Polyhedron (po_temp);
+  free_poly_ddr (tpddr);
+
+  if (dump_file && (dump_flags & TDF_DETAILS))
+    fprintf (dump_file, "\nloop carries dependency.\n");
 
   return is_empty_p;
 }
@@ -649,7 +745,7 @@ graphite_legal_transform_bb (poly_bb_p pbb1, poly_bb_p pbb2)
 
   for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), i, pdr1); i++)
     for (j = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), j, pdr2); j++)
-      if (!graphite_legal_transform_dr (pbb1, pbb2, pdr1, pdr2))
+      if (!graphite_legal_transform_dr (pdr1, pdr2))
 	return false;
 
   return true;
@@ -678,66 +774,6 @@ graphite_legal_transform (scop_p scop)
   return true;
 }
 
-/* Remove all the dimensions except alias information at dimension
-   ALIAS_DIM.  */
-
-static void
-build_alias_set_powerset (ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset,
-			  ppl_dimension_type alias_dim)
-{
-  ppl_dimension_type *ds;
-  ppl_dimension_type access_dim;
-  unsigned i, pos = 0;
-
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (alias_powerset,
-						      &access_dim);
-  ds = XNEWVEC (ppl_dimension_type, access_dim-1);
-  for (i = 0; i < access_dim; i++)
-    {
-      if (i == alias_dim)
-	continue;
-
-      ds[pos] = i;
-      pos++;
-    }
-
-  ppl_Pointset_Powerset_C_Polyhedron_remove_space_dimensions (alias_powerset,
-							      ds,
-							      access_dim - 1);
-  free (ds);
-}
-
-/* Return true when PDR1 and PDR2 may alias.  */
-
-static bool
-poly_drs_may_alias_p (poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset1, alias_powerset2;
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses1 = PDR_ACCESSES (pdr1);
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses2 = PDR_ACCESSES (pdr2);
-  ppl_dimension_type alias_dim1 = pdr_alias_set_dim (pdr1);
-  ppl_dimension_type alias_dim2 = pdr_alias_set_dim (pdr2);
-  int empty_p;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&alias_powerset1, accesses1);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&alias_powerset2, accesses2);
-
-  build_alias_set_powerset (alias_powerset1, alias_dim1);
-  build_alias_set_powerset (alias_powerset2, alias_dim2);
-
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign
-    (alias_powerset1, alias_powerset2);
-
-  empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (alias_powerset1);
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset1);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset2);
-
-  return !empty_p;
-}
-
 /* Returns TRUE when the dependence polyhedron between PDR1 and
    PDR2 represents a loop carried dependence at level LEVEL.  */
 
@@ -745,37 +781,19 @@ static bool
 graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
 				     int level)
 {
-  poly_bb_p pbb1 = PDR_PBB (pdr1);
-  poly_bb_p pbb2 = PDR_PBB (pdr2);
-  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
-  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
-  ppl_Polyhedron_t so1 = PBB_TRANSFORMED_SCATTERING (pbb1);
-  ppl_Polyhedron_t so2 = PBB_TRANSFORMED_SCATTERING (pbb2);
   ppl_Pointset_Powerset_C_Polyhedron_t po;
   ppl_Pointset_Powerset_C_Polyhedron_t eqpp;
-  graphite_dim_t tdim1 = pbb_nb_scattering_transform (pbb1);
-  graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
+  graphite_dim_t tdim1 = pbb_nb_scattering_transform (PDR_PBB (pdr1));
+  graphite_dim_t ddim1 = pbb_dim_iter_domain (PDR_PBB (pdr1));
   ppl_dimension_type dim;
   bool empty_p;
-  poly_ddr_p pddr;
-  int obj_base_set1 = PDR_BASE_OBJECT_SET (pdr1);
-  int obj_base_set2 = PDR_BASE_OBJECT_SET (pdr2);
-
-  if ((pdr_read_p (pdr1) && pdr_read_p (pdr2))
-      || !poly_drs_may_alias_p (pdr1, pdr2))
-    return false;
-
-  if (obj_base_set1 != obj_base_set2)
-    return true;
-
-  if (PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2))
-    return false;
-
-  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
-				1, false);
+  poly_ddr_p pddr = dependence_polyhedron (pdr1, pdr2, 1, false);
 
   if (pddr_is_empty (pddr))
-    return false;
+    {
+      free_poly_ddr (pddr);
+      return false;
+    }
 
   po = PDDR_DDP (pddr);
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &dim);
@@ -785,6 +803,8 @@ graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
   empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (eqpp);
 
   ppl_delete_Pointset_Powerset_C_Polyhedron (eqpp);
+  free_poly_ddr (pddr);
+
   return !empty_p;
 }
 
@@ -825,7 +845,7 @@ dot_original_deps_stmt_1 (FILE *file, scop_p scop)
       {
 	for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	  for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	    if (build_pddr (pbb1, pbb2, pdr1, pdr2, 1, true))
+	    if (!pddr_is_empty (dependence_polyhedron (pdr1, pdr2, 1, true)))
 	      {
 		fprintf (file, "OS%d -> OS%d\n",
 			 pbb_index (pbb1), pbb_index (pbb2));
@@ -844,20 +864,26 @@ dot_transformed_deps_stmt_1 (FILE *file, scop_p scop)
   int i, j, k, l;
   poly_bb_p pbb1, pbb2;
   poly_dr_p pdr1, pdr2;
-  poly_ddr_p pddr;
 
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb1); i++)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       {
 	for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	  for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	    if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, 1, false)))
-	      {
-		fprintf (file, "TS%d -> TS%d\n",
-			 pbb_index (pbb1), pbb_index (pbb2));
-		free_poly_ddr (pddr);
-		goto done;
-	      }
+	    {
+	      poly_ddr_p pddr = dependence_polyhedron (pdr1, pdr2, 1, false);
+
+	      if (!pddr_is_empty (pddr))
+		{
+		  fprintf (file, "TS%d -> TS%d\n",
+			   pbb_index (pbb1), pbb_index (pbb2));
+
+		  free_poly_ddr (pddr);
+		  goto done;
+		}
+
+	      free_poly_ddr (pddr);
+	    }
       done:;
       }
 }
@@ -891,7 +917,7 @@ dot_original_deps (FILE *file, scop_p scop)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	  if (build_pddr (pbb1, pbb2, pdr1, pdr2, 1, true))
+	  if (!pddr_is_empty (dependence_polyhedron (pdr1, pdr2, 1, true)))
 	    fprintf (file, "OS%d_D%d -> OS%d_D%d\n",
 		     pbb_index (pbb1), PDR_ID (pdr1),
 		     pbb_index (pbb2), PDR_ID (pdr2));
@@ -906,19 +932,21 @@ dot_transformed_deps (FILE *file, scop_p scop)
   int i, j, k, l;
   poly_bb_p pbb1, pbb2;
   poly_dr_p pdr1, pdr2;
-  poly_ddr_p pddr;
 
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb1); i++)
     for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
       for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
 	for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
-	  if ((pddr = build_pddr (pbb1, pbb2, pdr1, pdr2, 1, false)))
-	    {
+	  {
+	    poly_ddr_p pddr = dependence_polyhedron (pdr1, pdr2, 1, false);
+
+	    if (!pddr_is_empty (pddr))
 	      fprintf (file, "TS%d_D%d -> TS%d_D%d\n",
 		       pbb_index (pbb1), PDR_ID (pdr1),
 		       pbb_index (pbb2), PDR_ID (pdr2));
-	      free_poly_ddr (pddr);
-	    }
+
+	    free_poly_ddr (pddr);
+	  }
 }
 
 /* Pretty print to FILE all the data dependences of SCoP in DOT
diff --git a/gcc/graphite-dependences.h b/gcc/graphite-dependences.h
index cd89ba3..f6f4fea 100644
--- a/gcc/graphite-dependences.h
+++ b/gcc/graphite-dependences.h
@@ -30,6 +30,8 @@ enum poly_dependence_kind {
   has_dependence
 };
 
+/* Represents a Polyhedral Data Dependence Relation.  */
+
 typedef struct poly_ddr
 {
   /* Source and sink data references of the dependence.  */
@@ -40,17 +42,23 @@ typedef struct poly_ddr
 
   enum poly_dependence_kind kind;
 
+  /* True when the dependence relation is for the original scattering.  */
+  bool original_scattering_p;
+
 } *poly_ddr_p;
 
 #define PDDR_SOURCE(PDDR) (PDDR->source)
 #define PDDR_SINK(PDDR) (PDDR->sink)
 #define PDDR_DDP(PDDR) (PDDR->ddp)
 #define PDDR_KIND(PDDR) (PDDR->kind)
+#define PDDR_ORIGINAL_SCATTERING_P(PDDR) (PDDR->original_scattering_p)
 
 extern int eq_poly_ddr_p (const void *, const void *);
 extern hashval_t hash_poly_ddr_p (const void *);
 extern void free_poly_ddr (void *);
 extern void dot_deps (scop_p);
 extern void dot_deps_stmt (scop_p);
+extern void print_pddr (FILE *, poly_ddr_p);
+extern void debug_pddr (poly_ddr_p);
 
 #endif
diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c
index 38faebd..0b76335 100644
--- a/gcc/graphite-ppl.c
+++ b/gcc/graphite-ppl.c
@@ -701,7 +701,7 @@ ppl_min_for_le_polyhedron (ppl_Polyhedron_t pol,
 }
 
 /* Builds a constraint in dimension DIM relating dimensions POS1 to
-   POS2 as "POS1 - POS2 CSTR_TYPE C" */
+   POS2 as "POS1 - POS2 + C CSTR_TYPE 0" */
 
 ppl_Constraint_t
 ppl_build_relation (int dim, int pos1, int pos2, int c,
diff --git a/gcc/sese.h b/gcc/sese.h
index a54854a..20dd1b0 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -390,7 +390,4 @@ nb_common_loops (sese region, gimple_bb_p gbb1, gimple_bb_p gbb2)
   return sese_loop_depth (region, common);
 }
 
-extern void print_gimple_bb (FILE *, gimple_bb_p, int, int);
-extern void debug_gbb (gimple_bb_p, int);
-
 #endif
-- 
1.6.3.3

>From 2083451506c1c69e0efe7583d942e1cfa0df7227 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Feb 2010 19:23:20 +0000
Subject: [PATCH 11/13] Fix testsuite.

2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>

	* testsuite/gcc.dg/graphite/interchange-mvt.c: Un-XFAILed.
	* testsuite/gcc.dg/graphite/scop-0.c: Fix spaces.
	* testsuite/gfortran.dg/graphite/block-1.f90: Rewrite expected output.
	* testsuite/gfortran.dg/graphite/block-2.f: Same.
	* testsuite/gfortran.dg/graphite/block-3.f90: Same.
	* testsuite/gfortran.dg/graphite/block-4.f90: Same.
	* testsuite/gfortran.dg/graphite/interchange-1.f: Un-XFAILed.
	* testsuite/gfortran.dg/graphite/interchange-3.f90: Un-XFAILed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156475 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite                             |   11 +++++++++++
 gcc/testsuite/gcc.dg/graphite/block-6.c            |    1 -
 gcc/testsuite/gcc.dg/graphite/interchange-mvt.c    |    2 +-
 gcc/testsuite/gcc.dg/graphite/scop-0.c             |    2 +-
 gcc/testsuite/gfortran.dg/graphite/block-1.f90     |    7 ++++---
 gcc/testsuite/gfortran.dg/graphite/block-2.f       |    5 +++--
 gcc/testsuite/gfortran.dg/graphite/block-3.f90     |    5 +++--
 gcc/testsuite/gfortran.dg/graphite/block-4.f90     |    5 +++--
 gcc/testsuite/gfortran.dg/graphite/interchange-1.f |    2 +-
 .../gfortran.dg/graphite/interchange-3.f90         |    2 +-
 10 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index c5d0efe..1989467 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,16 @@
 2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* testsuite/gcc.dg/graphite/interchange-mvt.c: Un-XFAILed.
+	* testsuite/gcc.dg/graphite/scop-0.c: Fix spaces.
+	* testsuite/gfortran.dg/graphite/block-1.f90: Rewrite expected output.
+	* testsuite/gfortran.dg/graphite/block-2.f: Same.
+	* testsuite/gfortran.dg/graphite/block-3.f90: Same.
+	* testsuite/gfortran.dg/graphite/block-4.f90: Same.
+	* testsuite/gfortran.dg/graphite/interchange-1.f: Un-XFAILed.
+	* testsuite/gfortran.dg/graphite/interchange-3.f90: Un-XFAILed.
+
+2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (new_poly_ddr): Initialize PDDR_KIND and
 	PDDR_ORIGINAL_SCATTERING_P.
 	(pddr_is_empty): Rewritten.
diff --git a/gcc/testsuite/gcc.dg/graphite/block-6.c b/gcc/testsuite/gcc.dg/graphite/block-6.c
index 171b1df..a147ab8 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-6.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-6.c
@@ -43,6 +43,5 @@ main (void)
   return res != 204007516;
 }
 
-
 /* { dg-final { scan-tree-dump-times "will be loop blocked" 0 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
index 1e44f0a..fd66079 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
@@ -52,6 +52,6 @@ main (void)
   return res != 199900000;
 }
 
-/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ 
+/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-0.c b/gcc/testsuite/gcc.dg/graphite/scop-0.c
index 067e7bc..120de9c 100644
--- a/gcc/testsuite/gcc.dg/graphite/scop-0.c
+++ b/gcc/testsuite/gcc.dg/graphite/scop-0.c
@@ -17,6 +17,6 @@ int toto()
   /* End scop 1. */
 }
 
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ 
+/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 
diff --git a/gcc/testsuite/gfortran.dg/graphite/block-1.f90 b/gcc/testsuite/gfortran.dg/graphite/block-1.f90
index 8125853..cea307e 100644
--- a/gcc/testsuite/gfortran.dg/graphite/block-1.f90
+++ b/gcc/testsuite/gfortran.dg/graphite/block-1.f90
@@ -3,10 +3,11 @@ subroutine matrix_multiply(a,b,c,n)
 real(8), dimension(n,n) :: a,b,c
 
 ! The following code is disabled for the moment.
-! c=0.d0
+c=0.d0
 
 end subroutine matrix_multiply
 
-! { dg-final { scan-tree-dump-times "Loop blocked" 2 "graphite" { xfail *-*-* } } } 
-! { dg-final { cleanup-tree-dump "graphite" } } 
+! { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite" } }
+! { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { cleanup-tree-dump "graphite" } }
 
diff --git a/gcc/testsuite/gfortran.dg/graphite/block-2.f b/gcc/testsuite/gfortran.dg/graphite/block-2.f
index 6c7ee6f..75fccca 100644
--- a/gcc/testsuite/gfortran.dg/graphite/block-2.f
+++ b/gcc/testsuite/gfortran.dg/graphite/block-2.f
@@ -16,5 +16,6 @@
       RETURN
       END
 
-! { dg-final { scan-tree-dump-times "Loop blocked" 3 "graphite" { xfail { "*-*-*" } } } } 
-! { dg-final { cleanup-tree-dump "graphite" } } 
+! { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite" } }
+! { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite" { xfail *-*-* } } }
+! { dg-final { cleanup-tree-dump "graphite" } }
diff --git a/gcc/testsuite/gfortran.dg/graphite/block-3.f90 b/gcc/testsuite/gfortran.dg/graphite/block-3.f90
index 1579e66..9a66adf 100644
--- a/gcc/testsuite/gfortran.dg/graphite/block-3.f90
+++ b/gcc/testsuite/gfortran.dg/graphite/block-3.f90
@@ -12,6 +12,7 @@ enddo
 
 end subroutine matrix_multiply
 
-! { dg-final { scan-tree-dump-times "Loop blocked" 2 "graphite" { xfail *-*-* } } } 
-! { dg-final { cleanup-tree-dump "graphite" } } 
+! { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { cleanup-tree-dump "graphite" } }
 
diff --git a/gcc/testsuite/gfortran.dg/graphite/block-4.f90 b/gcc/testsuite/gfortran.dg/graphite/block-4.f90
index f37d70a..061830f 100644
--- a/gcc/testsuite/gfortran.dg/graphite/block-4.f90
+++ b/gcc/testsuite/gfortran.dg/graphite/block-4.f90
@@ -15,6 +15,7 @@ enddo
 
 end subroutine matrix_multiply
 
-! { dg-final { scan-tree-dump-times "Loop blocked" 2 "graphite" { xfail *-*-* } } } 
-! { dg-final { cleanup-tree-dump "graphite" } } 
+! { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { cleanup-tree-dump "graphite" } }
 
diff --git a/gcc/testsuite/gfortran.dg/graphite/interchange-1.f b/gcc/testsuite/gfortran.dg/graphite/interchange-1.f
index 334fbd8..fad61e2 100644
--- a/gcc/testsuite/gfortran.dg/graphite/interchange-1.f
+++ b/gcc/testsuite/gfortran.dg/graphite/interchange-1.f
@@ -41,5 +41,5 @@
 ! known to be 4 in the inner two loops.  See interchange-2.f for the
 ! kernel from bwaves.
 
-! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } }
 ! { dg-final { cleanup-tree-dump "graphite" } }
diff --git a/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90 b/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
index 04f4a13..06da2b3 100644
--- a/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
+++ b/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
@@ -24,5 +24,5 @@ Program FOO
 
 end Program FOO
 
-! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } }
+! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } }
 ! { dg-final { cleanup-tree-dump "graphite" } }
-- 
1.6.3.3

>From 8feed581d4babaea3e0ab384d0da427423814e10 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Feb 2010 19:23:24 +0000
Subject: [PATCH 12/13] Do not FAIL in miscompiled runtime tests.

2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>

	* testsuite/gcc.dg/graphite/interchange-12.c: Return 0 to avoid
	the execution check to FAIL.  This testcase is miscompiled by Graphite
	and the check should be re-enabled.
	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
	* testsuite/gcc.dg/graphite/block-0.c: Same.
	* testsuite/gcc.dg/graphite/block-4.c: Same.
	* testsuite/gcc.dg/graphite/block-7.c: Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156476 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite                          |   10 ++++++++++
 gcc/testsuite/gcc.dg/graphite/block-0.c         |    3 +++
 gcc/testsuite/gcc.dg/graphite/block-4.c         |    3 +++
 gcc/testsuite/gcc.dg/graphite/block-7.c         |    3 +++
 gcc/testsuite/gcc.dg/graphite/interchange-12.c  |    3 +++
 gcc/testsuite/gcc.dg/graphite/interchange-mvt.c |    3 +++
 6 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 1989467..55a0b7a 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,15 @@
 2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* testsuite/gcc.dg/graphite/interchange-12.c: Return 0 to avoid
+	the execution check to FAIL.  This testcase is miscompiled by Graphite
+	and the check should be re-enabled.
+	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
+	* testsuite/gcc.dg/graphite/block-0.c: Same.
+	* testsuite/gcc.dg/graphite/block-4.c: Same.
+	* testsuite/gcc.dg/graphite/block-7.c: Same.
+
+2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* testsuite/gcc.dg/graphite/interchange-mvt.c: Un-XFAILed.
 	* testsuite/gcc.dg/graphite/scop-0.c: Fix spaces.
 	* testsuite/gfortran.dg/graphite/block-1.f90: Rewrite expected output.
diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c
index 112b889..e965017 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-0.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-0.c
@@ -32,6 +32,9 @@ main()
   fprintf (stderr, "res = %d \n", res);
 #endif
 
+  /* Avoid runtime check for this testcase, as it is miscompiled by
+     Graphite for the moment.  */
+  return 0;
   return res != 1999;
 }
 
diff --git a/gcc/testsuite/gcc.dg/graphite/block-4.c b/gcc/testsuite/gcc.dg/graphite/block-4.c
index 3019f79..e24def0 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-4.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-4.c
@@ -46,6 +46,9 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
+  /* Avoid runtime check for this testcase, as it is miscompiled by
+     Graphite for the moment.  */
+  return 0;
   return res != 998001;
 }
 
diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c
index 3e8ff92..9f057ca 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-7.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-7.c
@@ -44,6 +44,9 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
+  /* Avoid runtime check for this testcase, as it is miscompiled by
+     Graphite for the moment.  */
+  return 0;
   return res != 529340000;
 }
 
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
index dc5b138..0a6ed60 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-12.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
@@ -44,6 +44,9 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
+  /* Avoid runtime check for this testcase, as it is miscompiled by
+     Graphite for the moment.  */
+  return 0;
   return res != 2626800;
 }
 
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
index fd66079..7caaeed 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
@@ -49,6 +49,9 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
+  /* Avoid runtime check for this testcase, as it is miscompiled by
+     Graphite for the moment.  */
+  return 0;
   return res != 199900000;
 }
 
-- 
1.6.3.3

>From 9f8dce51b2b0c7413a449a70557eb2b7947a7656 Mon Sep 17 00:00:00 2001
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sat, 6 Feb 2010 07:13:39 +0000
Subject: [PATCH 13/13] Fix PR42637.

2010-02-05  Sebastian Pop  <sebastian.pop@amd.com>
	    Konrad Trifunovic  <konrad.trifunovic@inria.fr>

	PR middle-end/42637
	* graphite-dependences.c (build_lexicographical_constraint): Return
	a union of dependence polyhedra.
	(dependence_polyhedron_1): Adapt for build_lexicographical_constraint.

	* testsuite/gcc.dg/graphite/block-0.c: Enable runtime check.  XFAILed.
	* testsuite/gcc.dg/graphite/block-4.c: Same.
	* testsuite/gcc.dg/graphite/block-7.c: Same.
	* testsuite/gcc.dg/graphite/interchange-12.c: Same.
	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
	* testsuite/gfortran.dg/graphite/interchange-1.f: XFAILed.
	* testsuite/gfortran.dg/graphite/interchange-3.f90: XFAILed.
	* testsuite/gfortran.dg/graphite/run-id-1.f: New testcase for PR42637.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@156538 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.graphite                             |   17 +++++
 gcc/graphite-dependences.c                         |   75 ++++++++++---------
 gcc/testsuite/gcc.dg/graphite/block-0.c            |    5 +-
 gcc/testsuite/gcc.dg/graphite/block-4.c            |    5 +-
 gcc/testsuite/gcc.dg/graphite/block-7.c            |    5 +-
 gcc/testsuite/gcc.dg/graphite/interchange-12.c     |    5 +-
 gcc/testsuite/gcc.dg/graphite/interchange-mvt.c    |    5 +-
 gcc/testsuite/gfortran.dg/graphite/interchange-1.f |    2 +-
 .../gfortran.dg/graphite/interchange-3.f90         |    2 +-
 gcc/testsuite/gfortran.dg/graphite/run-id-1.f      |   47 ++++++++++++
 10 files changed, 110 insertions(+), 58 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/graphite/run-id-1.f

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 55a0b7a..5a6a919 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,20 @@
+2010-02-05  Sebastian Pop  <sebastian.pop@amd.com>
+	    Konrad Trifunovic  <konrad.trifunovic@inria.fr>
+
+	PR middle-end/42637
+	* graphite-dependences.c (build_lexicographical_constraint): Return
+	a union of dependence polyhedra.
+	(dependence_polyhedron_1): Adapt for build_lexicographical_constraint.
+
+	* testsuite/gcc.dg/graphite/block-0.c: Enable runtime check.  XFAILed.
+	* testsuite/gcc.dg/graphite/block-4.c: Same.
+	* testsuite/gcc.dg/graphite/block-7.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-12.c: Same.
+	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
+	* testsuite/gfortran.dg/graphite/interchange-1.f: XFAILed.
+	* testsuite/gfortran.dg/graphite/interchange-3.f90: XFAILed.
+	* testsuite/gfortran.dg/graphite/run-id-1.f: New testcase for PR42637.
+
 2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* testsuite/gcc.dg/graphite/interchange-12.c: Return 0 to avoid
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index a6a7e57..4dc5854 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -412,58 +412,56 @@ build_pairwise_scheduling (graphite_dim_t dim,
   return res;
 }
 
-/* Add to a non empty polyhedron RES the precedence constraints for
-   the lexicographical comparison of time vectors in RES following the
-   lexicographical order.  DIM is the dimension of the polyhedron RES.
+/* Add to a non empty polyhedron BAG the precedence constraints for
+   the lexicographical comparison of time vectors in BAG following the
+   lexicographical order.  DIM is the dimension of the polyhedron BAG.
    TDIM is the number of loops common to the two statements that are
    compared lexicographically, i.e. the number of loops containing
    both statements.  OFFSET is the number of dimensions needed to
    represent the first statement, i.e. dimT1 + dimI1 in the layout of
-   the RES polyhedron: T1|I1|T2|I2|S1|S2|G.  When DIRECTION is set to
+   the BAG polyhedron: T1|I1|T2|I2|S1|S2|G.  When DIRECTION is set to
    1, compute the direct dependence from PDR1 to PDR2, and when
    DIRECTION is -1, compute the reversed dependence relation, from
    PDR2 to PDR1.  */
 
-static void
-build_lexicographical_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res,
+static ppl_Pointset_Powerset_C_Polyhedron_t
+build_lexicographical_constraint (ppl_Pointset_Powerset_C_Polyhedron_t bag,
 				  graphite_dim_t dim,
 				  graphite_dim_t tdim,
 				  graphite_dim_t offset,
 				  int direction)
 {
   graphite_dim_t i;
+  ppl_Pointset_Powerset_C_Polyhedron_t res, lex;
 
-  for (i = 0; i < tdim - 1; i+=2)
-    {
-      ppl_Pointset_Powerset_C_Polyhedron_t ineq;
-      bool empty_p;
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&res, dim, 1);
 
-      /* Identify the static schedule dimensions.  */
-      ineq = build_pairwise_scheduling (dim, i, offset, 0);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (ineq, *res);
-      empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (ineq);
+  lex = build_pairwise_scheduling (dim, 0, offset, direction);
+  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (lex, bag);
 
-      if (empty_p)
-	{
-	  /* Add the lexicographical dynamic schedule dimension.  */
-	  if (i > 0)
-	    ineq = build_pairwise_scheduling (dim, i - 1, offset, direction);
+  if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (lex))
+    ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (res, lex);
 
-	  return;
-	}
+  ppl_delete_Pointset_Powerset_C_Polyhedron (lex);
+
+  for (i = 0; i < tdim - 1; i++)
+    {
+      ppl_Pointset_Powerset_C_Polyhedron_t sceq;
+
+      sceq = build_pairwise_scheduling (dim, i, offset, 0);
+      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (bag, sceq);
+      ppl_delete_Pointset_Powerset_C_Polyhedron (sceq);
+
+      lex = build_pairwise_scheduling (dim, i + 1, offset, direction);
+      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (lex, bag);
 
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, ineq);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (ineq);
+      if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (lex))
+	ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (res, lex);
 
-      /* Identify the dynamic schedule dimensions.  */
-      ineq = build_pairwise_scheduling (dim, i + 1, offset, 0);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, ineq);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (ineq);
+      ppl_delete_Pointset_Powerset_C_Polyhedron (lex);
     }
 
-  /* There is no dependence.  */
-  ppl_delete_Pointset_Powerset_C_Polyhedron (*res);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (res, dim, 1);
+  return res;
 }
 
 /* Build the dependence polyhedron for data references PDR1 and PDR2.
@@ -553,8 +551,13 @@ dependence_polyhedron_1 (poly_dr_p pdr1, poly_dr_p pdr2,
   ppl_delete_Pointset_Powerset_C_Polyhedron (dreq);
 
   if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (res))
-    build_lexicographical_constraint (&res, dim, MIN (tdim1, tdim2),
-				      tdim1 + ddim1, direction);
+    {
+      ppl_Pointset_Powerset_C_Polyhedron_t lex =
+	build_lexicographical_constraint (res, dim, MIN (tdim1, tdim2),
+					  tdim1 + ddim1, direction);
+      ppl_delete_Pointset_Powerset_C_Polyhedron (res);
+      res = lex;
+    }
 
   return res;
 }
diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c
index e965017..320ee79 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-0.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-0.c
@@ -32,11 +32,8 @@ main()
   fprintf (stderr, "res = %d \n", res);
 #endif
 
-  /* Avoid runtime check for this testcase, as it is miscompiled by
-     Graphite for the moment.  */
-  return 0;
   return res != 1999;
 }
 
-/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-4.c b/gcc/testsuite/gcc.dg/graphite/block-4.c
index e24def0..5092757 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-4.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-4.c
@@ -46,11 +46,8 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
-  /* Avoid runtime check for this testcase, as it is miscompiled by
-     Graphite for the moment.  */
-  return 0;
   return res != 998001;
 }
 
-/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c
index 9f057ca..a07ef11 100644
--- a/gcc/testsuite/gcc.dg/graphite/block-7.c
+++ b/gcc/testsuite/gcc.dg/graphite/block-7.c
@@ -44,11 +44,8 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
-  /* Avoid runtime check for this testcase, as it is miscompiled by
-     Graphite for the moment.  */
-  return 0;
   return res != 529340000;
 }
 
-/* { dg-final { scan-tree-dump-times "SCoP will be loop blocked" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
index 0a6ed60..c0e331b 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-12.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c
@@ -44,11 +44,8 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
-  /* Avoid runtime check for this testcase, as it is miscompiled by
-     Graphite for the moment.  */
-  return 0;
   return res != 2626800;
 }
 
-/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
index 7caaeed..a1310dd 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c
@@ -49,12 +49,9 @@ main (void)
   fprintf (stderr, "res = %d \n", res);
 #endif
 
-  /* Avoid runtime check for this testcase, as it is miscompiled by
-     Graphite for the moment.  */
-  return 0;
   return res != 199900000;
 }
 
-/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 
diff --git a/gcc/testsuite/gfortran.dg/graphite/interchange-1.f b/gcc/testsuite/gfortran.dg/graphite/interchange-1.f
index fad61e2..334fbd8 100644
--- a/gcc/testsuite/gfortran.dg/graphite/interchange-1.f
+++ b/gcc/testsuite/gfortran.dg/graphite/interchange-1.f
@@ -41,5 +41,5 @@
 ! known to be 4 in the inner two loops.  See interchange-2.f for the
 ! kernel from bwaves.
 
-! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } }
+! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } }
 ! { dg-final { cleanup-tree-dump "graphite" } }
diff --git a/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90 b/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
index 06da2b3..04f4a13 100644
--- a/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
+++ b/gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
@@ -24,5 +24,5 @@ Program FOO
 
 end Program FOO
 
-! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } }
+! { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } }
 ! { dg-final { cleanup-tree-dump "graphite" } }
diff --git a/gcc/testsuite/gfortran.dg/graphite/run-id-1.f b/gcc/testsuite/gfortran.dg/graphite/run-id-1.f
new file mode 100644
index 0000000..521d268
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/graphite/run-id-1.f
@@ -0,0 +1,47 @@
+      subroutine mul66(rt,rtt,r)
+      real*8 rt(6,6),r(6,6),rtt(6,6)
+      do i=1,6
+        do j=1,6
+          do ia=1,6
+            rtt(i,ia)=rt(i,j)*r(j,ia)+rtt(i,ia)
+          end do
+        end do
+      end do
+      end
+
+      program test
+      real*8 xj(6,6),w(6,6),w1(6,6)
+      parameter(idump=0)
+      integer i,j
+
+      do i=1,6
+        do j=1,6
+          xj(i,j) = 0.0d0
+          w1(i,j) = 0.0d0
+          w(i,j) = i * 10.0d0 + j;
+        end do
+      end do
+
+      xj(1,2) =  1.0d0
+      xj(2,1) = -1.0d0
+      xj(3,4) =  1.0d0
+      xj(4,3) = -1.0d0
+      xj(5,6) =  1.0d0
+      xj(6,5) = -1.0d0
+
+      call mul66(xj,w1,w)
+
+      if (idump.ne.0) then
+        write(6,*) 'w1 after call to mul66'
+        do i = 1,6
+          do j = 1,6
+            write(6,'(D15.7)') w1(i,j)
+          end do
+        end do
+      end if
+
+      if (w1(1,1).ne.21.0d0) then
+        call abort()
+      end if
+
+      end
-- 
1.6.3.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]