OSDN Git Service

Use PIP to determine the integer feasibility of a constraint system.
[pf3gnuchains/gcc-fork.git] / gcc / graphite-dependences.c
index 8c7a642..d1e7d69 100644 (file)
@@ -22,30 +22,17 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
-#include "ggc.h"
-#include "tree.h"
-#include "rtl.h"
-#include "basic-block.h"
-#include "diagnostic.h"
 #include "tree-flow.h"
-#include "toplev.h"
 #include "tree-dump.h"
-#include "timevar.h"
 #include "cfgloop.h"
 #include "tree-chrec.h"
 #include "tree-data-ref.h"
 #include "tree-scalar-evolution.h"
-#include "tree-pass.h"
-#include "domwalk.h"
-#include "pointer-set.h"
-#include "gimple.h"
+#include "sese.h"
 
 #ifdef HAVE_cloog
 #include "ppl_c.h"
-#include "sese.h"
 #include "graphite-ppl.h"
-#include "graphite.h"
 #include "graphite-poly.h"
 #include "graphite-dependences.h"
 
@@ -66,7 +53,9 @@ new_poly_ddr (poly_dr_p source, poly_dr_p sink,
   PDDR_DDP (pddr) = ddp;
   PDDR_ORIGINAL_SCATTERING_P (pddr) = original_scattering_p;
 
-  if (!ddp || ppl_Pointset_Powerset_C_Polyhedron_is_empty (ddp))
+  if (!ddp
+      || ppl_powerset_is_empty (ddp,
+                               scop_nb_params (PBB_SCOP (PDR_PBB (source)))))
     PDDR_KIND (pddr) = no_dependence;
   else
     PDDR_KIND (pddr) = has_dependence;
@@ -193,6 +182,7 @@ print_pddr (FILE *file, poly_ddr_p pddr)
       fprintf (file, "\n  dependence polyhedron (\n");
       print_dependence_polyhedron_layout (file, pddr);
       ppl_print_powerset_matrix (file, PDDR_DDP (pddr));
+      ppl_io_fprint_Pointset_Powerset_C_Polyhedron (file, PDDR_DDP (pddr));
       fprintf (file, ")\n");
     }
 
@@ -346,7 +336,9 @@ dr_equality_constraints (graphite_dim_t dim,
 /* Builds scheduling inequality constraints: when DIRECTION is
    1 builds a GE constraint,
    0 builds an EQ constraint,
-   -1 builds a LE constraint.  */
+   -1 builds a LE constraint.
+   DIM is the dimension of the scheduling space.
+   POS and POS + OFFSET are the dimensions that are related.  */
 
 static ppl_Pointset_Powerset_C_Polyhedron_t
 build_pairwise_scheduling (graphite_dim_t dim,
@@ -357,23 +349,28 @@ build_pairwise_scheduling (graphite_dim_t dim,
   ppl_Pointset_Powerset_C_Polyhedron_t res;
   ppl_Polyhedron_t equalities;
   ppl_Constraint_t cstr;
+  graphite_dim_t a = pos;
+  graphite_dim_t b = pos + offset;
 
   ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
 
   switch (direction)
     {
-    case -1:
-      cstr = ppl_build_relation (dim, pos, pos + offset, 1,
+    case 1:
+      /* Builds "a + 1 <= b.  */
+      cstr = ppl_build_relation (dim, a, b, 1,
                                 PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
       break;
 
     case 0:
-      cstr = ppl_build_relation (dim, pos, pos + offset, 0,
+      /* Builds "a = b.  */
+      cstr = ppl_build_relation (dim, a, b, 0,
                                 PPL_CONSTRAINT_TYPE_EQUAL);
       break;
 
-    case 1:
-      cstr = ppl_build_relation (dim, pos, pos + offset, -1,
+    case -1:
+      /* Builds "a >= b + 1.  */
+      cstr = ppl_build_relation (dim, a, b, -1,
                                 PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
       break;
 
@@ -399,13 +396,14 @@ build_pairwise_scheduling (graphite_dim_t dim,
    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.  */
+   PDR2 to PDR1.  GDIM is the number of parameters in the scop.  */
 
 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,
+                                 graphite_dim_t gdim,
                                  int direction)
 {
   graphite_dim_t i;
@@ -416,7 +414,7 @@ build_lexicographical_constraint (ppl_Pointset_Powerset_C_Polyhedron_t bag,
   lex = build_pairwise_scheduling (dim, 0, offset, direction);
   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (lex, bag);
 
-  if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (lex))
+  if (!ppl_powerset_is_empty (lex, gdim))
     ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (res, lex);
 
   ppl_delete_Pointset_Powerset_C_Polyhedron (lex);
@@ -429,10 +427,13 @@ build_lexicographical_constraint (ppl_Pointset_Powerset_C_Polyhedron_t bag,
       ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (bag, sceq);
       ppl_delete_Pointset_Powerset_C_Polyhedron (sceq);
 
+      if (ppl_powerset_is_empty (bag, gdim))
+       break;
+
       lex = build_pairwise_scheduling (dim, i + 1, offset, direction);
       ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (lex, bag);
 
-      if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (lex))
+      if (!ppl_powerset_is_empty (lex, gdim))
        ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (res, lex);
 
       ppl_delete_Pointset_Powerset_C_Polyhedron (lex);
@@ -511,11 +512,11 @@ dependence_polyhedron_1 (poly_dr_p pdr1, poly_dr_p pdr2,
   ppl_delete_Pointset_Powerset_C_Polyhedron (idr2);
   ppl_delete_Pointset_Powerset_C_Polyhedron (dreq);
 
-  if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (res))
+  if (!ppl_powerset_is_empty (res, gdim))
     {
       ppl_Pointset_Powerset_C_Polyhedron_t lex =
        build_lexicographical_constraint (res, dim, MIN (tdim1, tdim2),
-                                         tdim1 + ddim1, direction);
+                                         tdim1 + ddim1, gdim, direction);
       ppl_delete_Pointset_Powerset_C_Polyhedron (res);
       res = lex;
     }
@@ -684,7 +685,8 @@ graphite_legal_transform_dr (poly_dr_p pdr1, poly_dr_p pdr2)
   ppl_insert_dimensions_pointset (pt, otdim1 + ttdim1 + ddim1, otdim2);
 
   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (po_temp, pt);
-  is_empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (po_temp);
+  is_empty_p = ppl_powerset_is_empty (po_temp,
+                                     scop_nb_params (PBB_SCOP (pbb1)));
 
   ppl_delete_Pointset_Powerset_C_Polyhedron (po_temp);
   free_poly_ddr (tpddr);
@@ -785,7 +787,8 @@ graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
   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);
+  empty_p = ppl_powerset_is_empty
+    (eqpp, scop_nb_params (PBB_SCOP (PDR_PBB (pdr1))));
 
   ppl_delete_Pointset_Powerset_C_Polyhedron (eqpp);
   free_poly_ddr (pddr);
@@ -956,14 +959,13 @@ dot_deps (scop_p scop)
   /* When debugging, enable the following code.  This cannot be used
      in production compilers because it calls "system".  */
 #if 0
-  int x;
   FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
   gcc_assert (stream);
 
   dot_deps_1 (stream, scop);
   fclose (stream);
 
-  x = system ("dotty /tmp/scopdeps.dot &");
+  system ("dotty /tmp/scopdeps.dot &");
 #else
   dot_deps_1 (stderr, scop);
 #endif
@@ -977,14 +979,13 @@ dot_deps_stmt (scop_p scop)
   /* When debugging, enable the following code.  This cannot be used
      in production compilers because it calls "system".  */
 #if 0
-  int x;
   FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
   gcc_assert (stream);
 
   dot_deps_stmt_1 (stream, scop);
   fclose (stream);
 
-  x = system ("dotty /tmp/scopdeps.dot &");
+  system ("dotty /tmp/scopdeps.dot &");
 #else
   dot_deps_stmt_1 (stderr, scop);
 #endif