isl_set_lift: preserve structure of space
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 22 Dec 2010 14:13:44 +0000 (15:13 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 21 Feb 2011 10:52:06 +0000 (11:52 +0100)
Before, we would simply add extra variables to the dimension specification,
if needed, destroying any internal structure.  Now, we retain the original
dimension specification as the domain of a wrapped map.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_dim.c
isl_dim_private.h
isl_map.c

index 16088f0..df4c1f8 100644 (file)
--- a/isl_dim.c
+++ b/isl_dim.c
@@ -1189,3 +1189,27 @@ error:
        isl_dim_free(dst);
        return NULL;
 }
+
+/* Given a dimension specification "dim" of a set, create a dimension
+ * specification for the lift of the set.  In particular, the result
+ * is of the form [dim -> local[..]], with n_local variables in the
+ * range of the wrapped map.
+ */
+__isl_give isl_dim *isl_dim_lift(__isl_take isl_dim *dim, unsigned n_local)
+{
+       isl_dim *local_dim;
+
+       if (!dim)
+               return NULL;
+
+       local_dim = isl_dim_dup(dim);
+       local_dim = isl_dim_drop(local_dim, isl_dim_set, 0, dim->n_out);
+       local_dim = isl_dim_add(local_dim, isl_dim_set, n_local);
+       local_dim = isl_dim_set_tuple_name(local_dim, isl_dim_set, "local");
+       dim = isl_dim_join(isl_dim_from_domain(dim),
+                           isl_dim_from_range(local_dim));
+       dim = isl_dim_wrap(dim);
+       dim = isl_dim_set_tuple_name(dim, isl_dim_set, "lifted");
+
+       return dim;
+}
index 0b4931c..a8c6007 100644 (file)
@@ -31,3 +31,5 @@ __isl_give isl_dim *isl_dim_flatten(__isl_take isl_dim *dim);
 
 __isl_give isl_dim *isl_dim_replace(__isl_take isl_dim *dst,
        enum isl_dim_type type, __isl_keep isl_dim *src);
+
+__isl_give isl_dim *isl_dim_lift(__isl_take isl_dim *dim, unsigned n_local);
index 06aa85c..5d7cf9e 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -7390,15 +7390,12 @@ __isl_give isl_basic_set *isl_basic_set_lift(__isl_take isl_basic_set *bset)
        if (!bset)
                return NULL;
 
-       if (bset->n_div == 0)
-               return bset;
-
        bset = isl_basic_set_cow(bset);
        if (!bset)
                return NULL;
 
        dim = isl_basic_set_get_dim(bset);
-       dim = isl_dim_add(dim, isl_dim_set, bset->n_div);
+       dim = isl_dim_lift(dim, bset->n_div);
        if (!dim)
                goto error;
        isl_dim_free(bset->dim);
@@ -7424,8 +7421,6 @@ __isl_give isl_set *isl_set_lift(__isl_take isl_set *set)
 
        if (!set)
                return NULL;
-       if (set->n == 0 || set->p[0]->n_div == 0)
-               return set;
 
        set = isl_set_cow(set);
        if (!set)
@@ -7433,7 +7428,7 @@ __isl_give isl_set *isl_set_lift(__isl_take isl_set *set)
 
        n_div = set->p[0]->n_div;
        dim = isl_set_get_dim(set);
-       dim = isl_dim_add(dim, isl_dim_set, n_div);
+       dim = isl_dim_lift(dim, n_div);
        if (!dim)
                goto error;
        isl_dim_free(set->dim);