X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_ilp.c;h=e6bc62429a7159c63559fb3c471b41221afe04c2;hb=63fb8a7f484648c3caa25351c8c94ac2395ec563;hp=542778bc60cf8320fa47f85fb7a439c26da3e2c3;hpb=64e0c9a630d2cec74cc60b23156cf63a3083de43;p=platform%2Fupstream%2Fisl.git diff --git a/isl_ilp.c b/isl_ilp.c index 542778b..e6bc624 100644 --- a/isl_ilp.c +++ b/isl_ilp.c @@ -1,7 +1,7 @@ /* * Copyright 2008-2009 Katholieke Universiteit Leuven * - * Use of this software is governed by the GNU LGPLv2.1 license + * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, K.U.Leuven, Departement * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium @@ -42,7 +42,7 @@ static struct isl_basic_set *unit_box_base_points(struct isl_basic_set *bset) } total = isl_basic_set_total_dim(bset); - unit_box = isl_basic_set_alloc_dim(isl_basic_set_get_dim(bset), + unit_box = isl_basic_set_alloc_space(isl_basic_set_get_space(bset), 0, 0, bset->n_ineq); for (i = 0; i < bset->n_ineq; ++i) { @@ -380,7 +380,7 @@ enum isl_lp_result isl_basic_set_opt(__isl_keep isl_basic_set *bset, int max, return isl_lp_error; ctx = isl_aff_get_ctx(obj); - if (!isl_dim_equal(bset->dim, obj->ls->dim)) + if (!isl_space_is_equal(bset->dim, obj->ls->dim)) isl_die(ctx, isl_error_invalid, "spaces don't match", return isl_lp_error); if (!isl_int_is_one(obj->v->el[0])) @@ -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) {