add isl_basic_map_image_is_bounded
[platform/upstream/isl.git] / isl_coalesce.c
index 73f44ed..9f31441 100644 (file)
@@ -270,7 +270,8 @@ static int check_facets(struct isl_map *map, int i, int j,
        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)
@@ -395,7 +396,8 @@ static int is_extension(struct isl_map *map, int i, int j, int k,
        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)
@@ -582,7 +584,8 @@ static int can_wrap_in_facet(struct isl_map *map, int i, int j, int k,
 
        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;
 
@@ -700,8 +703,8 @@ static int wrap_in_facets(struct isl_map *map, int i, int j,
        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);
@@ -719,7 +722,8 @@ static int wrap_in_facets(struct isl_map *map, int i, int j,
 
                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;
 
@@ -1011,24 +1015,32 @@ static int coalesce_pair(struct isl_map *map, int i, int j,
        int *ineq_j = NULL;
 
        eq_i = eq_status_in(map, i, j, tabs);
+       if (!eq_i)
+               goto error;
        if (any(eq_i, 2 * map->p[i]->n_eq, STATUS_ERROR))
                goto error;
        if (any(eq_i, 2 * map->p[i]->n_eq, STATUS_SEPARATE))
                goto done;
 
        eq_j = eq_status_in(map, j, i, tabs);
+       if (!eq_j)
+               goto error;
        if (any(eq_j, 2 * map->p[j]->n_eq, STATUS_ERROR))
                goto error;
        if (any(eq_j, 2 * map->p[j]->n_eq, STATUS_SEPARATE))
                goto done;
 
        ineq_i = ineq_status_in(map, i, j, tabs);
+       if (!ineq_i)
+               goto error;
        if (any(ineq_i, map->p[i]->n_ineq, STATUS_ERROR))
                goto error;
        if (any(ineq_i, map->p[i]->n_ineq, STATUS_SEPARATE))
                goto done;
 
        ineq_j = ineq_status_in(map, j, i, tabs);
+       if (!ineq_j)
+               goto error;
        if (any(ineq_j, map->p[j]->n_ineq, STATUS_ERROR))
                goto error;
        if (any(ineq_j, map->p[j]->n_ineq, STATUS_SEPARATE))
@@ -1130,7 +1142,8 @@ struct isl_map *isl_map_coalesce(struct isl_map *map)
                if (!tabs[i])
                        goto error;
                if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_IMPLICIT))
-                       tabs[i] = isl_tab_detect_implicit_equalities(tabs[i]);
+                       if (isl_tab_detect_implicit_equalities(tabs[i]) < 0)
+                               goto error;
                if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_REDUNDANT))
                        if (isl_tab_detect_redundant(tabs[i]) < 0)
                                goto error;