OSDN Git Service

2009-10-16 Joel Sherrill <joel.sherrill@oarcorp.com>
[pf3gnuchains/gcc-fork.git] / gcc / graphite-interchange.c
index c9da69b..0a751d6 100644 (file)
@@ -53,35 +53,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "graphite.h"
 #include "graphite-poly.h"
 
-/* Return in RES the maximum of the linear expression LE on polyhedron PS.  */
-
-static void
-ppl_max_for_le (ppl_Pointset_Powerset_C_Polyhedron_t ps,
-               ppl_Linear_Expression_t le, Value res)
-{
-  ppl_Coefficient_t num, denom;
-  Value dv, nv;
-  int maximum;
-
-  value_init (nv);
-  value_init (dv);
-  ppl_new_Coefficient (&num);
-  ppl_new_Coefficient (&denom);
-  ppl_Pointset_Powerset_C_Polyhedron_maximize (ps, le, num, denom, &maximum);
-
-  if (maximum)
-    {
-      ppl_Coefficient_to_mpz_t (num, nv);
-      ppl_Coefficient_to_mpz_t (denom, dv);
-      value_division (res, nv, dv);
-    }
-
-  value_clear (nv);
-  value_clear (dv);
-  ppl_delete_Coefficient (num);
-  ppl_delete_Coefficient (denom);
-}
-
 /* Builds a linear expression, of dimension DIM, representing PDR's
    memory access:
 
@@ -115,7 +86,7 @@ build_linearized_memory_access (poly_dr_p pdr)
 
       ppl_new_Linear_Expression_with_dimension (&le, dim);
       ppl_set_coef (le, i, 1);
-      ppl_max_for_le (PDR_ACCESSES (pdr), le, sub_size);
+      ppl_max_for_le_pointset (PDR_ACCESSES (pdr), le, sub_size);
       value_multiply (size, size, sub_size);
       ppl_delete_Linear_Expression (le);
     }
@@ -185,7 +156,7 @@ memory_stride_in_loop (Value stride, graphite_dim_t depth, poly_dr_p pdr)
   ppl_new_Linear_Expression_with_dimension (&le, new_dim);
   ppl_set_coef (le, dim_L2, 1);
   ppl_set_coef (le, dim_L1, -1);
-  ppl_max_for_le (p1, le, stride);
+  ppl_max_for_le_pointset (p1, le, stride);
   ppl_delete_Linear_Expression (le);
 }
 
@@ -273,7 +244,7 @@ pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2,
 {
   int i;
   poly_dr_p pdr;
-  Value d1, d2, s;
+  Value d1, d2, s, n;
   bool res;
 
   gcc_assert (depth1 < depth2);
@@ -283,13 +254,18 @@ pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2,
   value_init (d2);
   value_set_si (d2, 0);
   value_init (s);
+  value_init (n);
 
   for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++)
     {
+      value_set_si (n, PDR_NB_REFS (pdr));
+
       memory_stride_in_loop (s, depth1, pdr);
+      value_multiply (s, s, n);
       value_addto (d1, d1, s);
 
       memory_stride_in_loop (s, depth2, pdr);
+      value_multiply (s, s, n);
       value_addto (d2, d2, s);
     }
 
@@ -298,6 +274,7 @@ pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2,
   value_clear (d1);
   value_clear (d2);
   value_clear (s);
+  value_clear (n);
 
   return res;
 }