From 457c67345fb0449fe68705e46e19de9495164c5e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 22 Aug 2017 17:18:11 +0200 Subject: [PATCH] isl_tab_basic_set_non_trivial_lexmin: extract out init_lexmin_data This reduces the size of isl_tab_basic_set_non_trivial_lexmin. Signed-off-by: Sven Verdoolaege --- isl_tab_pip.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/isl_tab_pip.c b/isl_tab_pip.c index 54bd2037..57e1c590 100644 --- a/isl_tab_pip.c +++ b/isl_tab_pip.c @@ -5278,6 +5278,31 @@ struct isl_local_region { struct isl_tab_undo *snap; }; +/* Initialize the global data structure "data" used while solving + * the ILP problem "bset". + */ +static isl_stat init_lexmin_data(struct isl_lexmin_data *data, + __isl_keep isl_basic_set *bset) +{ + isl_ctx *ctx; + + ctx = isl_basic_set_get_ctx(bset); + + data->tab = tab_for_lexmin(bset, NULL, 0, 0); + if (!data->tab) + return isl_stat_error; + + data->v = isl_vec_alloc(ctx, 1 + data->tab->n_var); + if (!data->v) + return isl_stat_error; + data->local = isl_calloc_array(ctx, struct isl_local_region, + data->n_region); + if (data->n_region && !data->local) + return isl_stat_error; + + return isl_stat_ok; +} + /* Mark all outer levels as requiring a better solution * in the next cases. */ @@ -5364,17 +5389,11 @@ __isl_give isl_vec *isl_tab_basic_set_non_trivial_lexmin( ctx = isl_basic_set_get_ctx(bset); sol = isl_vec_alloc(ctx, 0); - data.tab = tab_for_lexmin(bset, NULL, 0, 0); - if (!data.tab) + if (init_lexmin_data(&data, bset) < 0) goto error; data.tab->conflict = conflict; data.tab->conflict_user = user; - data.v = isl_vec_alloc(ctx, 1 + data.tab->n_var); - data.local = isl_calloc_array(ctx, struct isl_local_region, n_region); - if (!data.v || (n_region && !data.local)) - goto error; - level = 0; init = 1; -- 2.11.4.GIT