static struct isl_vec *outside_point(struct isl_tab *tab, isl_int *eq, int up)
{
struct isl_ctx *ctx;
- struct isl_vec *sample;
+ struct isl_vec *sample = NULL;
struct isl_tab_undo *snap;
unsigned dim;
int k;
if (isl_tab_extend_cons(tab, 1) < 0)
goto error;
- tab = isl_tab_add_ineq(tab, eq);
+ if (isl_tab_add_ineq(tab, eq) < 0)
+ goto error;
sample = isl_tab_sample(tab);
if (!tab)
goto error;
for (i = 0; i < bset->n_ineq; ++i)
- tab = isl_tab_add_ineq(tab, bset->ineq[i]);
+ if (isl_tab_add_ineq(tab, bset->ineq[i]) < 0)
+ goto error;
bset = isl_basic_set_add_constraints(combined, bset, 0);
tab = isl_tab_detect_implicit_equalities(tab);
tab = isl_tab_detect_redundant(tab);
bset = tab_cone->bset;
U = isl_mat_drop_cols(U, 0, tab->n_var - tab->n_unbounded);
for (i = 0; i < bset->n_ineq; ++i) {
+ int ok;
struct isl_vec *row = NULL;
if (isl_tab_is_equality(tab_cone, tab_cone->n_eq + i))
continue;
continue;
tab = isl_tab_extend(tab, 1);
isl_int_add(bset->ineq[i][0], bset->ineq[i][0], v);
- tab = isl_tab_add_ineq(tab, bset->ineq[i]);
+ ok = isl_tab_add_ineq(tab, bset->ineq[i]) >= 0;
isl_int_sub(bset->ineq[i][0], bset->ineq[i][0], v);
- if (!tab)
+ if (!ok)
goto error;
}
}
}
-struct isl_tab *isl_tab_mark_empty(struct isl_tab *tab)
+int isl_tab_mark_empty(struct isl_tab *tab)
{
if (!tab)
- return NULL;
+ return -1;
if (!tab->empty && tab->need_undo)
- if (isl_tab_push(tab, isl_tab_undo_empty) < 0) {
- isl_tab_free(tab);
- return NULL;
- }
+ if (isl_tab_push(tab, isl_tab_undo_empty) < 0)
+ return -1;
tab->empty = 1;
- return tab;
+ return 0;
}
/* Update the rows signs after a pivot of "row" and "col", with "row_sgn"
/* Add inequality "ineq" and check if it conflicts with the
* previously added constraints or if it is obviously redundant.
*/
-struct isl_tab *isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq)
+int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq)
{
int r;
int sgn;
isl_int cst;
if (!tab)
- return NULL;
+ return -1;
if (tab->bset) {
struct isl_basic_set *bset = tab->bset;
- isl_assert(tab->mat->ctx, tab->n_eq == bset->n_eq, goto error);
+ isl_assert(tab->mat->ctx, tab->n_eq == bset->n_eq, return -1);
isl_assert(tab->mat->ctx,
- tab->n_con == bset->n_eq + bset->n_ineq, goto error);
+ tab->n_con == bset->n_eq + bset->n_ineq, return -1);
tab->bset = isl_basic_set_add_ineq(tab->bset, ineq);
if (isl_tab_push(tab, isl_tab_undo_bset_ineq) < 0)
- goto error;
+ return -1;
if (!tab->bset)
- goto error;
+ return -1;
}
if (tab->cone) {
isl_int_init(cst);
isl_int_clear(cst);
}
if (r < 0)
- goto error;
+ return -1;
tab->con[r].is_nonneg = 1;
if (isl_tab_push_var(tab, isl_tab_undo_nonneg, &tab->con[r]) < 0)
- goto error;
+ return -1;
if (isl_tab_row_is_redundant(tab, tab->con[r].index)) {
if (isl_tab_mark_redundant(tab, tab->con[r].index) < 0)
- goto error;
- return tab;
+ return -1;
+ return 0;
}
sgn = restore_row(tab, &tab->con[r]);
if (sgn < -1)
- goto error;
+ return -1;
if (sgn < 0)
return isl_tab_mark_empty(tab);
if (tab->con[r].is_row && isl_tab_row_is_redundant(tab, tab->con[r].index))
if (isl_tab_mark_redundant(tab, tab->con[r].index) < 0)
- goto error;
- return tab;
-error:
- isl_tab_free(tab);
- return NULL;
+ return -1;
+ return 0;
}
/* Pivot a non-negative variable down until it reaches the value zero
sgn = sign_of_max(tab, var);
if (sgn < -1)
goto error;
- if (sgn < 0)
- return isl_tab_mark_empty(tab);
+ if (sgn < 0) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
}
var->is_nonneg = 1;
if (!tab)
return NULL;
tab->rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
- if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_EMPTY))
- return isl_tab_mark_empty(tab);
+ if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_EMPTY)) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
for (i = 0; i < bmap->n_eq; ++i) {
tab = add_eq(tab, bmap->eq[i]);
if (!tab)
return tab;
}
for (i = 0; i < bmap->n_ineq; ++i) {
- tab = isl_tab_add_ineq(tab, bmap->ineq[i]);
- if (!tab || tab->empty)
+ if (isl_tab_add_ineq(tab, bmap->ineq[i]) < 0)
+ goto error;
+ if (tab->empty)
return tab;
}
return tab;
+error:
+ isl_tab_free(tab);
+ return NULL;
}
struct isl_tab *isl_tab_from_basic_set(struct isl_basic_set *bset)
sgn = sign_of_max(tab, &tab->con[r]);
if (sgn < -1)
goto error;
- if (sgn < 0)
- return isl_tab_mark_empty(tab);
+ if (sgn < 0) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
tab->con[r].is_nonneg = 1;
if (isl_tab_push_var(tab, isl_tab_undo_nonneg, &tab->con[r]) < 0)
goto error;
unsigned flags) WARN_UNUSED;
struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
-struct isl_tab *isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED;
+int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED;
struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
struct isl_tab_var *isl_tab_var_from_row(struct isl_tab *tab, int i);
int isl_tab_mark_redundant(struct isl_tab *tab, int row) WARN_UNUSED;
-struct isl_tab *isl_tab_mark_empty(struct isl_tab *tab);
+int isl_tab_mark_empty(struct isl_tab *tab) WARN_UNUSED;
struct isl_tab *isl_tab_dup(struct isl_tab *tab);
struct isl_tab *isl_tab_product(struct isl_tab *tab1, struct isl_tab *tab2);
int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
return tab;
while ((row = first_neg(tab)) != -1) {
col = lexmin_pivot_col(tab, row);
- if (col >= tab->n_col)
- return isl_tab_mark_empty(tab);
+ if (col >= tab->n_col) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
if (col < 0)
goto error;
if (isl_tab_pivot(tab, row, col) < 0)
row = tab->con[r1].index;
if (is_constant(tab, row)) {
if (!isl_int_is_zero(tab->mat->row[row][1]) ||
- (tab->M && !isl_int_is_zero(tab->mat->row[row][2])))
- return isl_tab_mark_empty(tab);
+ (tab->M && !isl_int_is_zero(tab->mat->row[row][2]))) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
if (isl_tab_rollback(tab, snap) < 0)
goto error;
return tab;
return tab;
while ((row = first_non_integer(tab, &flags)) != -1) {
- if (ISL_FL_ISSET(flags, I_VAR))
- return isl_tab_mark_empty(tab);
+ if (ISL_FL_ISSET(flags, I_VAR)) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
row = add_cut(tab, row);
if (row < 0)
goto error;
if (!tab->row_sign)
goto error;
}
- if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_EMPTY))
- return isl_tab_mark_empty(tab);
+ if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_EMPTY)) {
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
+ return tab;
+ }
for (i = tab->n_param; i < tab->n_var - tab->n_div; ++i) {
tab->var[i].is_nonneg = 1;
struct isl_tab_undo *snap2;
struct isl_vec *ineq = NULL;
int r = 0;
+ int ok;
if (!isl_tab_var_from_row(tab, split)->is_nonneg)
continue;
ineq = get_row_parameter_ineq(tab, split);
if (!ineq)
return -1;
- context_tab = isl_tab_add_ineq(context_tab, ineq->el);
+ ok = isl_tab_add_ineq(context_tab, ineq->el) >= 0;
isl_vec_free(ineq);
+ if (!ok)
+ return -1;
snap2 = isl_tab_snap(context_tab);
ineq = get_row_parameter_ineq(tab, row);
if (!ineq)
return -1;
- context_tab = isl_tab_add_ineq(context_tab, ineq->el);
+ ok = isl_tab_add_ineq(context_tab, ineq->el) >= 0;
isl_vec_free(ineq);
+ if (!ok)
+ return -1;
var = &context_tab->con[context_tab->n_con - 1];
if (!context_tab->empty &&
!isl_tab_min_at_most_neg_one(context_tab, var))
isl_seq_clr(ineq->el, ineq->size);
for (i = 0; i < context_tab->n_var; ++i) {
isl_int_set_si(ineq->el[1 + i], 1);
- context_tab = isl_tab_add_ineq(context_tab, ineq->el);
+ if (isl_tab_add_ineq(context_tab, ineq->el) < 0)
+ goto error;
var = &context_tab->con[context_tab->n_con - 1];
if (!context_tab->empty &&
!isl_tab_min_at_most_neg_one(context_tab, var)) {
if (sample->size == 0) {
isl_vec_free(sample);
- cgbr->tab = isl_tab_mark_empty(cgbr->tab);
+ if (isl_tab_mark_empty(cgbr->tab) < 0)
+ goto error;
return;
}
if (isl_tab_extend_cons(cgbr->tab, 1) < 0)
goto error;
- cgbr->tab = isl_tab_add_ineq(cgbr->tab, ineq);
+ if (isl_tab_add_ineq(cgbr->tab, ineq) < 0)
+ goto error;
if (cgbr->shifted && !cgbr->shifted->empty && use_shifted(cgbr)) {
int i;
isl_int_add(ineq[0], ineq[0], ineq[1 + i]);
}
- cgbr->shifted = isl_tab_add_ineq(cgbr->shifted, ineq);
+ if (isl_tab_add_ineq(cgbr->shifted, ineq) < 0)
+ goto error;
for (i = 0; i < dim; ++i) {
if (!isl_int_is_neg(ineq[1 + i]))
if (cgbr->cone && cgbr->cone->n_col != cgbr->cone->n_dead) {
if (isl_tab_extend_cons(cgbr->cone, 1) < 0)
goto error;
- cgbr->cone = isl_tab_add_ineq(cgbr->cone, ineq);
+ if (isl_tab_add_ineq(cgbr->cone, ineq) < 0)
+ goto error;
}
return;
break;
if (ISL_FL_ISSET(flags, I_PAR)) {
if (ISL_FL_ISSET(flags, I_VAR)) {
- tab = isl_tab_mark_empty(tab);
+ if (isl_tab_mark_empty(tab) < 0)
+ goto error;
break;
}
row = add_cut(tab, row);