hide isl_basic_set internals
[platform/upstream/isl.git] / isl_tab_pip.c
index ed2e50f..acf6ead 100644 (file)
@@ -8,9 +8,10 @@
  */
 
 #include "isl_map_private.h"
-#include "isl_seq.h"
+#include <isl/seq.h>
 #include "isl_tab.h"
 #include "isl_sample.h"
+#include <isl_mat_private.h>
 
 /*
  * The implementation of parametric integer linear programming in this file
@@ -448,17 +449,17 @@ static void sol_add(struct isl_sol *sol, struct isl_tab *tab)
 
                isl_seq_clr(mat->row[1 + row], mat->n_col);
                if (!tab->var[i].is_row) {
-                       /* no unbounded */
-                       isl_assert(mat->ctx, !tab->M, goto error2);
+                       if (tab->M)
+                               isl_die(mat->ctx, isl_error_invalid,
+                                       "unbounded optimum", goto error2);
                        continue;
                }
 
                r = tab->var[i].index;
-               /* no unbounded */
-               if (tab->M)
-                       isl_assert(mat->ctx, isl_int_eq(tab->mat->row[r][2],
-                                                       tab->mat->row[r][0]),
-                                   goto error2);
+               if (tab->M &&
+                   isl_int_ne(tab->mat->row[r][2], tab->mat->row[r][0]))
+                       isl_die(mat->ctx, isl_error_invalid,
+                               "unbounded optimum", goto error2);
                isl_int_gcd(m, mat->row[0][0], tab->mat->row[r][0]);
                isl_int_divexact(m, tab->mat->row[r][0], m);
                scale_rows(mat, m, 1 + row);
@@ -1222,8 +1223,6 @@ static struct isl_tab *add_lexmin_valid_eq(struct isl_tab *tab, isl_int *eq)
                if (isl_tab_kill_col(tab, i) < 0)
                        goto error;
                tab->n_eq++;
-
-               tab = restore_lexmin(tab);
        }
 
        return tab;
@@ -1990,6 +1989,8 @@ static struct isl_tab *tab_for_lexmin(struct isl_basic_map *bmap,
                if (!tab || tab->empty)
                        return tab;
        }
+       if (bmap->n_eq)
+               tab = restore_lexmin(tab);
        for (i = 0; i < bmap->n_ineq; ++i) {
                if (max)
                        isl_seq_neg(bmap->ineq[i] + 1 + tab->n_param,
@@ -3895,7 +3896,7 @@ struct isl_map *isl_tab_basic_map_partial_lexopt(
        if (empty)
                *empty = NULL;
        if (!bmap || !dom)
-               goto error;
+               goto error2;
 
        isl_assert(bmap->ctx,
            isl_basic_map_compatible_domain(bmap, dom), goto error);
@@ -3934,6 +3935,8 @@ struct isl_map *isl_tab_basic_map_partial_lexopt(
        sol_free(&sol_map->sol);
        isl_basic_map_free(bmap);
        return result;
+error2:
+       isl_basic_set_free(dom);
 error:
        sol_free(&sol_map->sol);
        isl_basic_map_free(bmap);