diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 96c03db2ea6..61559f9f65b 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,8 @@ +2009-10-17 Sebastian Pop + + * graphite-ppl.c (ppl_min_for_le_polyhedron): New. + * graphite-ppl.h (graphite-ppl.h): Declared. + 2009-10-17 Sebastian Pop * graphite-ppl.c (ppl_print_linear_expr): New. diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c index 241171c9ed1..b47e24a4ab4 100644 --- a/gcc/graphite-ppl.c +++ b/gcc/graphite-ppl.c @@ -669,4 +669,36 @@ ppl_max_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t ps, ppl_delete_Coefficient (denom); } +/* Return in RES the maximum of the linear expression LE on the + polyhedron POL. */ + +void +ppl_min_for_le_polyhedron (ppl_Polyhedron_t pol, + ppl_Linear_Expression_t le, Value res) +{ + ppl_Coefficient_t num, denom; + Value dv, nv; + int maximum, err; + + value_init (nv); + value_init (dv); + ppl_new_Coefficient (&num); + ppl_new_Coefficient (&denom); + err = ppl_Polyhedron_minimize (pol, le, num, denom, &maximum); + + if (err > 0) + { + ppl_Coefficient_to_mpz_t (num, nv); + ppl_Coefficient_to_mpz_t (denom, dv); + gcc_assert (value_notzero_p (dv)); + value_division (res, nv, dv); + } + + value_clear (nv); + value_clear (dv); + ppl_delete_Coefficient (num); + ppl_delete_Coefficient (denom); +} + + #endif diff --git a/gcc/graphite-ppl.h b/gcc/graphite-ppl.h index 64c79f4a253..f7dc2b31ed2 100644 --- a/gcc/graphite-ppl.h +++ b/gcc/graphite-ppl.h @@ -48,7 +48,8 @@ void ppl_set_inhomogeneous_gmp (ppl_Linear_Expression_t, Value); void ppl_set_coef_gmp (ppl_Linear_Expression_t, ppl_dimension_type, Value); 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); /* Assigns to RES the value of the INTEGER_CST T. */