Fix a typo in isl_term_dup
[platform/upstream/isl.git] / isl_coalesce.c
index a07d983..531cbdc 100644 (file)
@@ -158,7 +158,7 @@ static int fuse(struct isl_map *map, int i, int j,
        unsigned total = isl_basic_map_total_dim(map->p[i]);
        unsigned extra_rows = extra ? extra->n_row : 0;
 
-       fused = isl_basic_map_alloc_dim(isl_dim_copy(map->p[i]->dim),
+       fused = isl_basic_map_alloc_space(isl_space_copy(map->p[i]->dim),
                        map->p[i]->n_div,
                        map->p[i]->n_eq + map->p[j]->n_eq,
                        map->p[i]->n_ineq + map->p[j]->n_ineq + extra_rows);
@@ -223,7 +223,7 @@ static int fuse(struct isl_map *map, int i, int j,
            ISL_F_ISSET(map->p[j], ISL_BASIC_MAP_RATIONAL))
                ISL_F_SET(fused, ISL_BASIC_MAP_RATIONAL);
 
-       fused_tab = isl_tab_from_basic_map(fused);
+       fused_tab = isl_tab_from_basic_map(fused, 0);
        if (isl_tab_detect_redundant(fused_tab) < 0)
                goto error;
 
@@ -711,13 +711,16 @@ static int wrap_in_facets(struct isl_map *map, int i, int j,
                set_is_redundant(tabs[i], map->p[i]->n_eq, cuts, n, k, 1);
 
                isl_seq_neg(bound->el, map->p[i]->ineq[cuts[k]], 1 + total);
-               if (add_wraps(wraps, map->p[i], tabs[i], bound->el, set) < 0)
+               if (!tabs[i]->empty &&
+                   add_wraps(wraps, map->p[i], tabs[i], bound->el, set) < 0)
                        goto error;
 
                set_is_redundant(tabs[i], map->p[i]->n_eq, cuts, n, k, 0);
                if (isl_tab_rollback(tabs[i], snap_i) < 0)
                        goto error;
 
+               if (tabs[i]->empty)
+                       break;
                if (!wraps->n_row)
                        break;
 
@@ -1242,7 +1245,7 @@ struct isl_map *isl_map_coalesce(struct isl_map *map)
 
        n = map->n;
        for (i = 0; i < map->n; ++i) {
-               tabs[i] = isl_tab_from_basic_map(map->p[i]);
+               tabs[i] = isl_tab_from_basic_map(map->p[i], 0);
                if (!tabs[i])
                        goto error;
                if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_IMPLICIT))
@@ -1280,6 +1283,7 @@ error:
                for (i = 0; i < n; ++i)
                        isl_tab_free(tabs[i]);
        free(tabs);
+       isl_map_free(map);
        return NULL;
 }