add isl_map_order_lt
[platform/upstream/isl.git] / isl_map.c
index 691c88c..8e26ac0 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -534,7 +534,7 @@ __isl_give isl_basic_map *isl_basic_map_set_dim_name(
        bmap->dim = isl_space_set_dim_name(bmap->dim, type, pos, s);
        if (!bmap->dim)
                goto error;
-       return bmap;
+       return isl_basic_map_finalize(bmap);
 error:
        isl_basic_map_free(bmap);
        return NULL;
@@ -9819,6 +9819,7 @@ __isl_give isl_basic_map *isl_basic_map_zip(__isl_take isl_basic_map *bmap)
                isl_space_dim(bmap->dim->nested[0], isl_dim_in);
        n1 = isl_space_dim(bmap->dim->nested[0], isl_dim_out);
        n2 = isl_space_dim(bmap->dim->nested[1], isl_dim_in);
+       bmap = isl_basic_map_cow(bmap);
        bmap = isl_basic_map_swap_vars(bmap, pos, n1, n2);
        if (!bmap)
                return NULL;
@@ -10095,6 +10096,9 @@ static __isl_give isl_basic_map *equator(__isl_take isl_space *space,
                isl_die(isl_space_get_ctx(space), isl_error_invalid,
                        "index out of bounds", goto error);
 
+       if (type1 == type2 && pos1 == pos2)
+               return isl_basic_map_universe(space);
+
        bmap = isl_basic_map_alloc_space(isl_space_copy(space), 0, 1, 0);
        i = isl_basic_map_alloc_equality(bmap);
        if (i < 0)
@@ -10198,6 +10202,12 @@ __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
                isl_die(map->ctx, isl_error_invalid,
                        "index out of bounds", goto error);
 
+       if (type1 == type2 && pos1 == pos2) {
+               isl_space *space = isl_map_get_space(map);
+               isl_map_free(map);
+               return isl_map_empty(space);
+       }
+
        bmap = isl_basic_map_alloc_space(isl_map_get_space(map), 0, 0, 1);
        i = isl_basic_map_alloc_inequality(bmap);
        if (i < 0)
@@ -10219,6 +10229,15 @@ error:
        return NULL;
 }
 
+/* Add a constraint imposing that the value of the first dimension is
+ * smaller than that of the second.
+ */
+__isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
+       enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2)
+{
+       return isl_map_order_gt(map, type2, pos2, type1, pos1);
+}
+
 __isl_give isl_aff *isl_basic_map_get_div(__isl_keep isl_basic_map *bmap,
        int pos)
 {