add isl_set_complement
[platform/upstream/isl.git] / isl_coalesce.c
index bdf20eb..f5f637c 100644 (file)
@@ -166,6 +166,7 @@ static int fuse(struct isl_map *map, int i, int j,
        for (k = 0; k < map->p[i]->n_eq; ++k) {
                if (eq_i && (eq_i[2 * k] != STATUS_VALID ||
                             eq_i[2 * k + 1] != STATUS_VALID))
+                       continue;
                l = isl_basic_map_alloc_equality(fused);
                if (l < 0)
                        goto error;
@@ -200,6 +201,13 @@ static int fuse(struct isl_map *map, int i, int j,
                isl_seq_cpy(fused->ineq[l], map->p[j]->ineq[k], 1 + total);
        }
 
+       for (k = 0; k < map->p[i]->n_div; ++k) {
+               int l = isl_basic_map_alloc_div(fused);
+               if (l < 0)
+                       goto error;
+               isl_seq_cpy(fused->div[l], map->p[i]->div[k], 1 + 1 + total);
+       }
+
        for (k = 0; k < extra_rows; ++k) {
                l = isl_basic_map_alloc_inequality(fused);
                if (l < 0)
@@ -481,7 +489,7 @@ unbounded:
  * to have been restricted to this facet, so that the non-redundant
  * constraints in tab[j] are the ridges of the facet.
  * Note that for the purpose of wrapping, it does not matter whether
- * we wrap the ridges of i aronud the whole of j or just around
+ * we wrap the ridges of i around the whole of j or just around
  * the facet since all the other constraints are assumed to be valid for j.
  * In practice, we wrap to include the whole of j.
  *        ____                   _____
@@ -591,10 +599,13 @@ static int can_wrap_in_set(struct isl_map *map, int i, int j,
        isl_assert(map->ctx, k < map->p[i]->n_ineq, return -1);
 
        isl_int_add_ui(map->p[i]->ineq[k][0], map->p[i]->ineq[k][0], 1);
-       for (l = 0; l < map->p[j]->n_ineq; ++l)
+       for (l = 0; l < map->p[j]->n_ineq; ++l) {
+               if (isl_tab_is_redundant(tabs[j], map->p[j]->n_eq + l))
+                       continue;
                if (isl_seq_eq(map->p[i]->ineq[k],
                                map->p[j]->ineq[l], 1 + total))
                        break;
+       }
        isl_int_sub_ui(map->p[i]->ineq[k][0], map->p[i]->ineq[k][0], 1);
 
        if (l >= map->p[j]->n_ineq)