From 492e5a43304fb02f77571bb0c40f789bcb920c61 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 10 May 2012 15:57:06 +0200 Subject: [PATCH] isl_set_opt: align parameters Signed-off-by: Sven Verdoolaege --- isl_ilp.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/isl_ilp.c b/isl_ilp.c index abfac26..bcaa313 100644 --- a/isl_ilp.c +++ b/isl_ilp.c @@ -427,8 +427,10 @@ error: /* Compute the minimum (maximum if max is set) of the integer affine * expression obj over the points in set and put the result in *opt. + * + * The parameters are assumed to have been aligned. */ -enum isl_lp_result isl_set_opt(__isl_keep isl_set *set, int max, +static enum isl_lp_result isl_set_opt_aligned(__isl_keep isl_set *set, int max, __isl_keep isl_aff *obj, isl_int *opt) { int i; @@ -466,6 +468,34 @@ enum isl_lp_result isl_set_opt(__isl_keep isl_set *set, int max, return empty ? isl_lp_empty : isl_lp_ok; } +/* Compute the minimum (maximum if max is set) of the integer affine + * expression obj over the points in set and put the result in *opt. + */ +enum isl_lp_result isl_set_opt(__isl_keep isl_set *set, int max, + __isl_keep isl_aff *obj, isl_int *opt) +{ + enum isl_lp_result res; + + if (!set || !obj) + return isl_lp_error; + + if (isl_space_match(set->dim, isl_dim_param, + obj->ls->dim, isl_dim_param)) + return isl_set_opt_aligned(set, max, obj, opt); + + set = isl_set_copy(set); + obj = isl_aff_copy(obj); + set = isl_set_align_params(set, isl_aff_get_domain_space(obj)); + obj = isl_aff_align_params(obj, isl_set_get_space(set)); + + res = isl_set_opt_aligned(set, max, obj, opt); + + isl_set_free(set); + isl_aff_free(obj); + + return res; +} + enum isl_lp_result isl_basic_set_max(__isl_keep isl_basic_set *bset, __isl_keep isl_aff *obj, isl_int *opt) { -- 2.7.4