X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_ilp.c;h=24f6c57c93d2966c4572855265472f6836ea682f;hb=de51a9bc4da5dd3f1f9f57c2362da6f9752c44e0;hp=abfac265ace6bd6a67b34bc3e2ebf726206a6b81;hpb=d07eed3bf4d0e290118588ca80997a8035eaeb21;p=platform%2Fupstream%2Fisl.git diff --git a/isl_ilp.c b/isl_ilp.c index abfac26..24f6c57 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 @@ -375,6 +375,7 @@ enum isl_lp_result isl_basic_set_opt(__isl_keep isl_basic_set *bset, int max, isl_mat *bset_div = NULL; isl_mat *div = NULL; enum isl_lp_result res; + int bset_n_div; if (!bset || !obj) return isl_lp_error; @@ -388,14 +389,15 @@ enum isl_lp_result isl_basic_set_opt(__isl_keep isl_basic_set *bset, int max, "expecting integer affine expression", return isl_lp_error); - if (bset->n_div == 0 && obj->ls->div->n_row == 0) + bset_n_div = isl_basic_set_dim(bset, isl_dim_div); + if (bset_n_div == 0 && obj->ls->div->n_row == 0) return basic_set_opt(bset, max, obj, opt); bset = isl_basic_set_copy(bset); obj = isl_aff_copy(obj); bset_div = extract_divs(bset); - exp1 = isl_alloc_array(ctx, int, bset_div->n_row); + exp1 = isl_alloc_array(ctx, int, bset_n_div); exp2 = isl_alloc_array(ctx, int, obj->ls->div->n_row); if (!bset_div || !exp1 || !exp2) goto error; @@ -427,8 +429,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 +470,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) {