return -1;
isl_int_neg(lp->row->el[0], lp->tmp);
- lp->tab = isl_tab_add_eq(lp->tab, lp->row->el);
+ if (isl_tab_add_eq(lp->tab, lp->row->el) < 0)
+ return -1;
isl_seq_cpy(lp->row->el + 1 + lp->dim, row, lp->dim);
isl_seq_clr(lp->row->el + 1, lp->dim);
- lp->tab = isl_tab_add_eq(lp->tab, lp->row->el);
+ if (isl_tab_add_eq(lp->tab, lp->row->el) < 0)
+ return -1;
lp->con_offset += 2;
break;
isl_vec_free(sample);
- tab = isl_tab_add_eq(tab, hull->eq[j]);
- if (!tab)
+ if (isl_tab_add_eq(tab, hull->eq[j]) < 0)
goto error;
}
if (j == hull->n_eq)
if (hull->n_eq > tab->n_zero) {
for (j = 0; j < hull->n_eq; ++j) {
isl_seq_normalize(tab->mat->ctx, hull->eq[j], 1 + tab->n_var);
- tab = isl_tab_add_eq(tab, hull->eq[j]);
+ if (isl_tab_add_eq(tab, hull->eq[j]) < 0)
+ goto error;
}
}
isl_seq_cpy(bound->el, map->p[i]->ineq[cuts[k]], 1 + total);
isl_int_add_ui(bound->el[0], bound->el[0], 1);
- tabs[j] = isl_tab_add_eq(tabs[j], bound->el);
+ if (isl_tab_add_eq(tabs[j], bound->el) < 0)
+ goto error;
if (isl_tab_detect_redundant(tabs[j]) < 0)
goto error;
/* Add equality "eq" and check if it conflicts with the
* previously added constraints or if it is obviously redundant.
*/
-struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq)
+int isl_tab_add_eq(struct isl_tab *tab, isl_int *eq)
{
struct isl_tab_undo *snap = NULL;
struct isl_tab_var *var;
isl_int cst;
if (!tab)
- return NULL;
- isl_assert(tab->mat->ctx, !tab->M, goto error);
+ return -1;
+ isl_assert(tab->mat->ctx, !tab->M, return -1);
if (tab->need_undo)
snap = isl_tab_snap(tab);
isl_int_clear(cst);
}
if (r < 0)
- goto error;
+ return -1;
var = &tab->con[r];
row = var->index;
if (row_is_manifestly_zero(tab, row)) {
if (snap) {
if (isl_tab_rollback(tab, snap) < 0)
- goto error;
+ return -1;
} else
drop_row(tab, row);
- return tab;
+ return 0;
}
if (tab->bmap) {
tab->bmap = isl_basic_map_add_ineq(tab->bmap, eq);
if (isl_tab_push(tab, isl_tab_undo_bmap_ineq) < 0)
- goto error;
+ return -1;
isl_seq_neg(eq, eq, 1 + tab->n_var);
tab->bmap = isl_basic_map_add_ineq(tab->bmap, eq);
isl_seq_neg(eq, eq, 1 + tab->n_var);
if (isl_tab_push(tab, isl_tab_undo_bmap_ineq) < 0)
- goto error;
+ return -1;
if (!tab->bmap)
- goto error;
+ return -1;
if (add_zero_row(tab) < 0)
- goto error;
+ return -1;
}
sgn = isl_int_sgn(tab->mat->row[row][1]);
if (sgn < 0) {
sgn = sign_of_max(tab, var);
if (sgn < -1)
- goto error;
+ return -1;
if (sgn < 0) {
if (isl_tab_mark_empty(tab) < 0)
- goto error;
- return tab;
+ return -1;
+ return 0;
}
}
var->is_nonneg = 1;
if (to_col(tab, var) < 0)
- goto error;
+ return -1;
var->is_nonneg = 0;
if (isl_tab_kill_col(tab, var->index) < 0)
- goto error;
+ return -1;
- return tab;
-error:
- isl_tab_free(tab);
- return NULL;
+ return 0;
}
/* Construct and return an inequality that expresses an upper bound
isl_int_init(cst);
for (i = 0; i < bset->n_eq; ++i) {
isl_int_swap(bset->eq[i][offset], cst);
- if (offset > 0)
- tab = isl_tab_add_eq(tab, bset->eq[i] + offset);
- else
+ if (offset > 0) {
+ if (isl_tab_add_eq(tab, bset->eq[i] + offset) < 0)
+ goto error;
+ } else
tab = add_eq(tab, bset->eq[i]);
isl_int_swap(bset->eq[i][offset], cst);
if (!tab)
struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) 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;
+int 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;
int isl_tab_freeze_constraint(struct isl_tab *tab, int con) WARN_UNUSED;
if (isl_tab_extend_cons(tab, 2) < 0)
goto error;
- tab = isl_tab_add_eq(tab, eq);
+ if (isl_tab_add_eq(tab, eq) < 0)
+ goto error;
return tab;
error:
if (cgbr->cone && cgbr->cone->n_col != cgbr->cone->n_dead) {
if (isl_tab_extend_cons(cgbr->cone, 2) < 0)
goto error;
- cgbr->cone = isl_tab_add_eq(cgbr->cone, eq);
+ if (isl_tab_add_eq(cgbr->cone, eq) < 0)
+ goto error;
}
if (check) {
isl_int_set_si(c->el[0], 0);
for (i = 0; i < bset->n_eq; ++i) {
isl_seq_cpy(c->el + 1, bset->eq[i], c->size - 1);
- tab = isl_tab_add_eq(tab, c->el);
- if (!tab) {
- isl_vec_free(c);
- return tab;
- }
+ if (isl_tab_add_eq(tab, c->el) < 0)
+ goto error;
}
isl_int_set_si(c->el[0], -1);