From 4e2cbb309f88e1d847d55dbd81d900b22151a866 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 28 Nov 2009 20:16:03 +0100 Subject: [PATCH] isl_tab_detect_redundant: return status instead of isl_tab * --- isl_coalesce.c | 7 ++++--- isl_convex_hull.c | 7 ++++++- isl_map_simplify.c | 5 +++-- isl_tab.c | 17 +++++++---------- isl_tab.h | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/isl_coalesce.c b/isl_coalesce.c index 0716916f..33399d92 100644 --- a/isl_coalesce.c +++ b/isl_coalesce.c @@ -184,8 +184,7 @@ static int fuse(struct isl_map *map, int i, int j, struct isl_tab **tabs, ISL_F_SET(fused, ISL_BASIC_MAP_RATIONAL); fused_tab = isl_tab_from_basic_map(fused); - fused_tab = isl_tab_detect_redundant(fused_tab); - if (!fused_tab) + if (isl_tab_detect_redundant(fused_tab) < 0) goto error; isl_basic_map_free(map->p[i]); @@ -196,6 +195,7 @@ static int fuse(struct isl_map *map, int i, int j, struct isl_tab **tabs, return 1; error: + isl_tab_free(fused_tab); isl_basic_map_free(fused); return -1; } @@ -582,7 +582,8 @@ struct isl_map *isl_map_coalesce(struct isl_map *map) if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_IMPLICIT)) tabs[i] = isl_tab_detect_implicit_equalities(tabs[i]); if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_REDUNDANT)) - tabs[i] = isl_tab_detect_redundant(tabs[i]); + if (isl_tab_detect_redundant(tabs[i]) < 0) + goto error; } for (i = map->n - 1; i >= 0; --i) if (tabs[i]->empty) diff --git a/isl_convex_hull.c b/isl_convex_hull.c index d50b0540..c6f28069 100644 --- a/isl_convex_hull.c +++ b/isl_convex_hull.c @@ -95,12 +95,17 @@ struct isl_basic_map *isl_basic_map_convex_hull(struct isl_basic_map *bmap) tab = isl_tab_from_basic_map(bmap); tab = isl_tab_detect_implicit_equalities(tab); - tab = isl_tab_detect_redundant(tab); + if (isl_tab_detect_redundant(tab) < 0) + goto error; bmap = isl_basic_map_update_from_tab(bmap, tab); isl_tab_free(tab); ISL_F_SET(bmap, ISL_BASIC_MAP_NO_IMPLICIT); ISL_F_SET(bmap, ISL_BASIC_MAP_NO_REDUNDANT); return bmap; +error: + isl_tab_free(tab); + isl_basic_map_free(bmap); + return NULL; } struct isl_basic_set *isl_basic_set_convex_hull(struct isl_basic_set *bset) diff --git a/isl_map_simplify.c b/isl_map_simplify.c index e17dffb9..41fee622 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -1586,9 +1586,10 @@ static struct isl_basic_set *uset_gist(struct isl_basic_set *bset, goto error; bset = isl_basic_set_add_constraints(combined, bset, 0); tab = isl_tab_detect_implicit_equalities(tab); - tab = isl_tab_detect_redundant(tab); - if (!tab) + if (isl_tab_detect_redundant(tab) < 0) { + isl_tab_free(tab); goto error2; + } for (i = 0; i < context_ineq; ++i) { tab->con[i].is_zero = 0; tab->con[i].is_redundant = 1; diff --git a/isl_tab.c b/isl_tab.c index 2583e091..23493e89 100644 --- a/isl_tab.c +++ b/isl_tab.c @@ -2421,17 +2421,17 @@ static int con_is_redundant(struct isl_tab *tab, struct isl_tab_var *var) * If not, we mark the row as being redundant (assuming it hasn't * been detected as being obviously redundant in the mean time). */ -struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab) +int isl_tab_detect_redundant(struct isl_tab *tab) { int i; unsigned n_marked; if (!tab) - return NULL; + return -1; if (tab->empty) - return tab; + return 0; if (tab->n_redundant == tab->n_row) - return tab; + return 0; n_marked = 0; for (i = tab->n_redundant; i < tab->n_row; ++i) { @@ -2468,10 +2468,10 @@ struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab) n_marked--; red = con_is_redundant(tab, var); if (red < 0) - goto error; + return -1; if (red && !var->is_redundant) if (isl_tab_mark_redundant(tab, var->index) < 0) - goto error; + return -1; for (i = tab->n_dead; i < tab->n_col; ++i) { var = var_from_col(tab, i); if (!var->marked) @@ -2483,10 +2483,7 @@ struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab) } } - return tab; -error: - isl_tab_free(tab); - return NULL; + return 0; } int isl_tab_is_equality(struct isl_tab *tab, int con) diff --git a/isl_tab.h b/isl_tab.h index 920dea75..bf9ef88f 100644 --- a/isl_tab.h +++ b/isl_tab.h @@ -173,7 +173,7 @@ struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap, struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset, struct isl_tab *tab); struct isl_tab *isl_tab_detect_implicit_equalities(struct isl_tab *tab) WARN_UNUSED; -struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab) WARN_UNUSED; +int isl_tab_detect_redundant(struct isl_tab *tab) WARN_UNUSED; #define ISL_TAB_SAVE_DUAL (1 << 0) enum isl_lp_result isl_tab_min(struct isl_tab *tab, isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom, -- 2.11.4.GIT