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]);
return 1;
error:
+ isl_tab_free(fused_tab);
isl_basic_map_free(fused);
return -1;
}
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)
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)
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;
* 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) {
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)
}
}
- return tab;
-error:
- isl_tab_free(tab);
- return NULL;
+ return 0;
}
int isl_tab_is_equality(struct isl_tab *tab, int con)
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,