for (k = 0; k < map->p[i]->n_ineq; ++k) {
if (ineq_i[k] != STATUS_CUT)
continue;
- tabs[i] = isl_tab_select_facet(tabs[i], n_eq + k);
+ if (isl_tab_select_facet(tabs[i], n_eq + k) < 0)
+ return -1;
for (l = 0; l < map->p[j]->n_ineq; ++l) {
int stat;
if (ineq_j[l] != STATUS_CUT)
snap = isl_tab_snap(tabs[i]);
tabs[i] = isl_tab_relax(tabs[i], n_eq + k);
snap2 = isl_tab_snap(tabs[i]);
- tabs[i] = isl_tab_select_facet(tabs[i], n_eq + k);
+ if (isl_tab_select_facet(tabs[i], n_eq + k) < 0)
+ return -1;
super = contains(map, j, ineq_j, tabs[i]);
if (super) {
if (isl_tab_rollback(tabs[i], snap2) < 0)
snap = isl_tab_snap(tabs[i]);
- tabs[i] = isl_tab_select_facet(tabs[i], map->p[i]->n_eq + k);
+ if (isl_tab_select_facet(tabs[i], map->p[i]->n_eq + k) < 0)
+ goto error;
if (isl_tab_detect_redundant(tabs[i]) < 0)
goto error;
wraps->n_row = 0;
for (k = 0; k < n; ++k) {
- tabs[i] = isl_tab_select_facet(tabs[i],
- map->p[i]->n_eq + cuts[k]);
+ if (isl_tab_select_facet(tabs[i], map->p[i]->n_eq + cuts[k]) < 0)
+ goto error;
if (isl_tab_detect_redundant(tabs[i]) < 0)
goto error;
set_is_redundant(tabs[i], map->p[i]->n_eq, cuts, n, k, 1);
* the resulting tableau is empty.
* Otherwise, we know the value will be zero and we close the row.
*/
-static struct isl_tab *cut_to_hyperplane(struct isl_tab *tab,
- struct isl_tab_var *var)
+static int cut_to_hyperplane(struct isl_tab *tab, struct isl_tab_var *var)
{
unsigned r;
isl_int *row;
unsigned off = 2 + tab->M;
if (var->is_zero)
- return tab;
- isl_assert(tab->mat->ctx, !var->is_redundant, goto error);
- isl_assert(tab->mat->ctx, var->is_nonneg, goto error);
+ return 0;
+ isl_assert(tab->mat->ctx, !var->is_redundant, return -1);
+ isl_assert(tab->mat->ctx, var->is_nonneg, return -1);
if (isl_tab_extend_cons(tab, 1) < 0)
- goto error;
+ return -1;
r = tab->n_con;
tab->con[r].index = tab->n_row;
tab->n_row++;
tab->n_con++;
if (isl_tab_push_var(tab, isl_tab_undo_allocate, &tab->con[r]) < 0)
- goto error;
+ return -1;
sgn = sign_of_max(tab, &tab->con[r]);
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;
}
tab->con[r].is_nonneg = 1;
if (isl_tab_push_var(tab, isl_tab_undo_nonneg, &tab->con[r]) < 0)
- goto error;
+ return -1;
/* sgn == 0 */
if (close_row(tab, &tab->con[r]) < 0)
- goto error;
+ return -1;
- return tab;
-error:
- isl_tab_free(tab);
- return NULL;
+ return 0;
}
/* Given a tableau "tab" and an inequality constraint "con" of the tableau,
return NULL;
}
-struct isl_tab *isl_tab_select_facet(struct isl_tab *tab, int con)
+int isl_tab_select_facet(struct isl_tab *tab, int con)
{
if (!tab)
- return NULL;
+ return -1;
return cut_to_hyperplane(tab, &tab->con[con]);
}
if (close_row(tab, var) < 0)
goto error;
} else if (!tab->rational && !at_least_one(tab, var)) {
- tab = cut_to_hyperplane(tab, var);
+ if (cut_to_hyperplane(tab, var) < 0)
+ goto error;
return isl_tab_detect_implicit_equalities(tab);
}
for (i = tab->n_redundant; i < tab->n_row; ++i) {
int isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap) WARN_UNUSED;
struct isl_tab *isl_tab_relax(struct isl_tab *tab, int con) WARN_UNUSED;
-struct isl_tab *isl_tab_select_facet(struct isl_tab *tab, int con) WARN_UNUSED;
+int isl_tab_select_facet(struct isl_tab *tab, int con) WARN_UNUSED;
void isl_tab_dump(struct isl_tab *tab, FILE *out, int indent);