add isl_set_from_pw_aff
[platform/upstream/isl.git] / isl_test.c
index c5e3e83..77d5cb9 100644 (file)
@@ -128,6 +128,18 @@ void test_parse(struct isl_ctx *ctx)
        str2 = "{ [i,j] : i < j or i > j }";
        test_parse_map_equal(ctx, str, str2);
 
+       str = "{ [i,j] : (i+1)*2 >= j }";
+       str2 = "{ [i, j] : j <= 2 + 2i }";
+       test_parse_map_equal(ctx, str, str2);
+
+       str = "{ [i] -> [i > 0 ? 4 : 5] }";
+       str2 = "{ [i] -> [5] : i <= 0; [i] -> [4] : i >= 1 }";
+       test_parse_map_equal(ctx, str, str2);
+
+       str = "[N=2,M] -> { [i=[(M+N)/4]] }";
+       str2 = "[N, M] -> { [i] : N = 2 and 4i <= 2 + M and 4i >= -1 + M }";
+       test_parse_map_equal(ctx, str, str2);
+
        test_parse_pwqp(ctx, "{ [i] -> i + [ (i + [i/3])/2 ] }");
        test_parse_map(ctx, "{ S1[i] -> [([i/10]),i%10] : 0 <= i <= 45 }");
 }
@@ -181,23 +193,23 @@ void test_bounded(struct isl_ctx *ctx)
 void test_construction(struct isl_ctx *ctx)
 {
        isl_int v;
-       struct isl_dim *dim;
+       isl_space *dim;
        struct isl_basic_set *bset;
        struct isl_constraint *c;
 
        isl_int_init(v);
 
-       dim = isl_dim_set_alloc(ctx, 1, 1);
+       dim = isl_space_set_alloc(ctx, 1, 1);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_inequality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_inequality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, 1);
        isl_constraint_set_coefficient(c, isl_dim_param, 0, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_inequality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_inequality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -5);
@@ -243,17 +255,17 @@ void test_dim(struct isl_ctx *ctx)
 void test_div(struct isl_ctx *ctx)
 {
        isl_int v;
-       struct isl_dim *dim;
+       isl_space *dim;
        struct isl_basic_set *bset;
        struct isl_constraint *c;
 
        isl_int_init(v);
 
        /* test 1 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, 1);
@@ -262,7 +274,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, -1);
@@ -277,10 +289,10 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 2 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, -1);
@@ -289,7 +301,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, 1);
@@ -304,10 +316,10 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 3 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, -1);
@@ -316,7 +328,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -3);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, 1);
@@ -331,10 +343,10 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 4 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 2);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, -1);
@@ -343,7 +355,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_constant(c, v);
        isl_int_set_si(v, 1);
@@ -358,17 +370,17 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 5 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, 3);
        isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -3);
@@ -381,17 +393,17 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 6 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, 6);
        isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -3);
@@ -413,10 +425,10 @@ void test_div(struct isl_ctx *ctx)
         * and we end up with the original equality and div again.
         * Perhaps we can avoid the introduction of this temporary div.
         */
-       dim = isl_dim_set_alloc(ctx, 0, 4);
+       dim = isl_space_set_alloc(ctx, 0, 4);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -3);
@@ -436,10 +448,10 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 8 */
-       dim = isl_dim_set_alloc(ctx, 0, 5);
+       dim = isl_space_set_alloc(ctx, 0, 5);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -3);
@@ -450,7 +462,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 4, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, 1);
@@ -468,10 +480,10 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 9 */
-       dim = isl_dim_set_alloc(ctx, 0, 4);
+       dim = isl_space_set_alloc(ctx, 0, 4);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -1);
@@ -480,7 +492,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, -1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, 3);
@@ -498,10 +510,10 @@ void test_div(struct isl_ctx *ctx)
        isl_basic_set_free(bset);
 
        /* test 10 */
-       dim = isl_dim_set_alloc(ctx, 0, 3);
+       dim = isl_space_set_alloc(ctx, 0, 3);
        bset = isl_basic_set_universe(dim);
 
-       c = isl_equality_alloc(isl_basic_set_get_dim(bset));
+       c = isl_equality_alloc(isl_basic_set_get_space(bset));
        isl_int_set_si(v, 1);
        isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
        isl_int_set_si(v, -2);
@@ -1216,10 +1228,10 @@ void test_closure(struct isl_ctx *ctx)
 
 void test_lex(struct isl_ctx *ctx)
 {
-       isl_dim *dim;
+       isl_space *dim;
        isl_map *map;
 
-       dim = isl_dim_alloc(ctx, 0, 0, 0);
+       dim = isl_space_alloc(ctx, 0, 0, 0);
        map = isl_map_lex_le(dim);
        assert(!isl_map_is_empty(map));
        isl_map_free(map);
@@ -1228,11 +1240,11 @@ void test_lex(struct isl_ctx *ctx)
 static int consume_lexmin(__isl_take isl_basic_set *dom,
        __isl_take isl_aff_list *list, void *user)
 {
-       isl_dim *dim;
+       isl_space *dim;
        isl_basic_map *bmap;
        isl_map **map = user;
 
-       dim = isl_basic_set_get_dim(dom);
+       dim = isl_basic_set_get_space(dom);
        bmap = isl_basic_map_from_aff_list(dim, list);
        bmap = isl_basic_map_intersect_domain(bmap, dom);
 
@@ -1308,7 +1320,7 @@ void test_lexmin(struct isl_ctx *ctx)
        str = "{ [i] -> [i', j] : j = i - 8i' and i' >= 0 and i' <= 7 and "
                                " 8i' <= i and 8i' >= -7 + i }";
        bmap = isl_basic_map_read_from_str(ctx, str, -1);
-       map2 = isl_map_empty(isl_basic_map_get_dim(bmap));
+       map2 = isl_map_empty(isl_basic_map_get_space(bmap));
        isl_basic_map_foreach_lexmin(bmap, &consume_lexmin, &map2);
        map = isl_map_from_basic_map(bmap);
        assert(isl_map_is_equal(map, map2));
@@ -1358,7 +1370,7 @@ static int map_is_equal(__isl_keep isl_map *map, const char *str)
 void test_dep(struct isl_ctx *ctx)
 {
        const char *str;
-       isl_dim *dim;
+       isl_space *dim;
        isl_map *map;
        isl_access_info *ai;
        isl_flow *flow;
@@ -1380,8 +1392,8 @@ void test_dep(struct isl_ctx *ctx)
        ai = isl_access_info_add_source(ai, map, 1, &depth);
 
        flow = isl_access_info_compute_flow(ai);
-       dim = isl_dim_alloc(ctx, 0, 3, 3);
-       mm.must = isl_map_empty(isl_dim_copy(dim));
+       dim = isl_space_alloc(ctx, 0, 3, 3);
+       mm.must = isl_map_empty(isl_space_copy(dim));
        mm.may = isl_map_empty(dim);
 
        isl_flow_foreach(flow, collect_must_may, &mm);
@@ -1410,8 +1422,8 @@ void test_dep(struct isl_ctx *ctx)
        ai = isl_access_info_add_source(ai, map, 0, &depth);
 
        flow = isl_access_info_compute_flow(ai);
-       dim = isl_dim_alloc(ctx, 0, 3, 3);
-       mm.must = isl_map_empty(isl_dim_copy(dim));
+       dim = isl_space_alloc(ctx, 0, 3, 3);
+       mm.must = isl_map_empty(isl_space_copy(dim));
        mm.may = isl_map_empty(dim);
 
        isl_flow_foreach(flow, collect_must_may, &mm);
@@ -1439,8 +1451,8 @@ void test_dep(struct isl_ctx *ctx)
        ai = isl_access_info_add_source(ai, map, 0, &depth);
 
        flow = isl_access_info_compute_flow(ai);
-       dim = isl_dim_alloc(ctx, 0, 3, 3);
-       mm.must = isl_map_empty(isl_dim_copy(dim));
+       dim = isl_space_alloc(ctx, 0, 3, 3);
+       mm.must = isl_map_empty(isl_space_copy(dim));
        mm.may = isl_map_empty(dim);
 
        isl_flow_foreach(flow, collect_must_may, &mm);
@@ -1469,8 +1481,8 @@ void test_dep(struct isl_ctx *ctx)
        ai = isl_access_info_add_source(ai, map, 0, &depth);
 
        flow = isl_access_info_compute_flow(ai);
-       dim = isl_dim_alloc(ctx, 0, 3, 3);
-       mm.must = isl_map_empty(isl_dim_copy(dim));
+       dim = isl_space_alloc(ctx, 0, 3, 3);
+       mm.must = isl_map_empty(isl_space_copy(dim));
        mm.may = isl_map_empty(dim);
 
        isl_flow_foreach(flow, collect_must_may, &mm);
@@ -1499,8 +1511,8 @@ void test_dep(struct isl_ctx *ctx)
        ai = isl_access_info_add_source(ai, map, 0, &depth);
 
        flow = isl_access_info_compute_flow(ai);
-       dim = isl_dim_alloc(ctx, 0, 3, 3);
-       mm.must = isl_map_empty(isl_dim_copy(dim));
+       dim = isl_space_alloc(ctx, 0, 3, 3);
+       mm.must = isl_map_empty(isl_space_copy(dim));
        mm.may = isl_map_empty(dim);
 
        isl_flow_foreach(flow, collect_must_may, &mm);
@@ -1527,8 +1539,8 @@ void test_dep(struct isl_ctx *ctx)
        ai = isl_access_info_add_source(ai, map, 1, &depth);
 
        flow = isl_access_info_compute_flow(ai);
-       dim = isl_dim_alloc(ctx, 0, 5, 5);
-       mm.must = isl_map_empty(isl_dim_copy(dim));
+       dim = isl_space_alloc(ctx, 0, 5, 5);
+       mm.must = isl_map_empty(isl_space_copy(dim));
        mm.may = isl_map_empty(dim);
 
        isl_flow_foreach(flow, collect_must_may, &mm);
@@ -1887,7 +1899,7 @@ int test_one_schedule(isl_ctx *ctx, const char *d, const char *w,
        W = isl_union_map_intersect_domain(W, isl_union_set_copy(D));
        R = isl_union_map_intersect_domain(R, isl_union_set_copy(D));
 
-       empty = isl_union_map_empty(isl_union_map_get_dim(S));
+       empty = isl_union_map_empty(isl_union_map_get_space(S));
         isl_union_map_compute_flow(isl_union_map_copy(R),
                                   isl_union_map_copy(W), empty,
                                   isl_union_map_copy(S),
@@ -1932,19 +1944,19 @@ int test_one_schedule(isl_ctx *ctx, const char *d, const char *w,
        } else {
                delta_set = isl_set_from_union_set(delta);
 
-               slice = isl_set_universe(isl_set_get_dim(delta_set));
+               slice = isl_set_universe(isl_set_get_space(delta_set));
                for (i = 0; i < tilable; ++i)
                        slice = isl_set_lower_bound_si(slice, isl_dim_set, i, 0);
                is_tilable = isl_set_is_subset(delta_set, slice);
                isl_set_free(slice);
 
-               slice = isl_set_universe(isl_set_get_dim(delta_set));
+               slice = isl_set_universe(isl_set_get_space(delta_set));
                for (i = 0; i < parallel; ++i)
                        slice = isl_set_fix_si(slice, isl_dim_set, i, 0);
                is_parallel = isl_set_is_subset(delta_set, slice);
                isl_set_free(slice);
 
-               origin = isl_set_universe(isl_set_get_dim(delta_set));
+               origin = isl_set_universe(isl_set_get_space(delta_set));
                for (i = 0; i < isl_set_dim(origin, isl_dim_set); ++i)
                        origin = isl_set_fix_si(origin, isl_dim_set, i, 0);
 
@@ -2172,6 +2184,21 @@ int test_schedule(isl_ctx *ctx)
        if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
                return -1;
 
+       D = "[n] -> { S_0[j, k] : j <= -1 + n and j >= 0 and "
+                               "k <= -1 + n and k >= 0 }";
+       W = "[n] -> { S_0[j, k] -> B[j] : j <= -1 + n and j >= 0 and "                                                  "k <= -1 + n and k >= 0 }";
+       R = "[n] -> { S_0[j, k] -> B[j] : j <= -1 + n and j >= 0 and "
+                                       "k <= -1 + n and k >= 0; "
+                   "S_0[j, k] -> B[k] : j <= -1 + n and j >= 0 and "
+                                       "k <= -1 + n and k >= 0; "
+                   "S_0[j, k] -> A[k] : j <= -1 + n and j >= 0 and "
+                                       "k <= -1 + n and k >= 0 }";
+       S = "[n] -> { S_0[j, k] -> [2, j, k] }";
+       ctx->opt->schedule_outer_zero_distance = 1;
+       if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
+               return -1;
+       ctx->opt->schedule_outer_zero_distance = 0;
+
        return test_special_schedule(ctx);
 }
 
@@ -2230,13 +2257,13 @@ int test_aff(isl_ctx *ctx)
 {
        const char *str;
        isl_set *set;
-       isl_dim *dim;
+       isl_space *dim;
        isl_local_space *ls;
        isl_aff *aff;
        int zero;
 
-       dim = isl_dim_set_alloc(ctx, 0, 1);
-       ls = isl_local_space_from_dim(dim);
+       dim = isl_space_set_alloc(ctx, 0, 1);
+       ls = isl_local_space_from_space(dim);
        aff = isl_aff_zero(ls);
 
        aff = isl_aff_add_coefficient_si(aff, isl_dim_set, 0, 1);
@@ -2267,19 +2294,20 @@ int test_dim_max(isl_ctx *ctx)
 {
        int equal;
        const char *str;
-       isl_map *map, *map2;
+       isl_set *set1, *set2;
        isl_set *set;
+       isl_map *map;
        isl_pw_aff *pwaff;
 
        str = "[N] -> { [i] : 0 <= i <= min(N,10) }";
        set = isl_set_read_from_str(ctx, str, -1);
        pwaff = isl_set_dim_max(set, 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N] -> { [] -> [10] : N >= 10; [] -> [N] : N <= 9 and N >= 0 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N] -> { [10] : N >= 10; [N] : N <= 9 and N >= 0 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
        if (equal < 0)
                return -1;
        if (!equal)
@@ -2288,12 +2316,12 @@ int test_dim_max(isl_ctx *ctx)
        str = "[N] -> { [i] : 0 <= i <= max(2N,N+6) }";
        set = isl_set_read_from_str(ctx, str, -1);
        pwaff = isl_set_dim_max(set, 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N] -> { [] -> [6 + N] : -6 <= N <= 5; [] -> [2N] : N >= 6 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
        if (equal < 0)
                return -1;
        if (!equal)
@@ -2302,12 +2330,12 @@ int test_dim_max(isl_ctx *ctx)
        str = "[N] -> { [i] : 0 <= i <= 2N or 0 <= i <= N+6 }";
        set = isl_set_read_from_str(ctx, str, -1);
        pwaff = isl_set_dim_max(set, 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N] -> { [] -> [6 + N] : -6 <= N <= 5; [] -> [2N] : N >= 6 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
        if (equal < 0)
                return -1;
        if (!equal)
@@ -2319,21 +2347,21 @@ int test_dim_max(isl_ctx *ctx)
        set = isl_map_range(map);
 
        pwaff = isl_set_dim_max(isl_set_copy(set), 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N,M] -> { [] -> [([(N-1)/16])] : M,N > 0 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N,M] -> { [([(N-1)/16])] : M,N > 0 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
 
        pwaff = isl_set_dim_max(isl_set_copy(set), 3);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N,M] -> { [] -> [t] : t = min(M-1,15) and M,N > 0 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N,M] -> { [t] : t = min(M-1,15) and M,N > 0 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
        if (equal >= 0 && equal)
-               equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+               equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
 
        isl_set_free(set);
 
@@ -2345,6 +2373,90 @@ int test_dim_max(isl_ctx *ctx)
        return 0;
 }
 
+int test_product(isl_ctx *ctx)
+{
+       const char *str;
+       isl_set *set;
+       int ok;
+
+       str = "{ A[i] }";
+       set = isl_set_read_from_str(ctx, str, -1);
+       set = isl_set_product(set, isl_set_copy(set));
+       ok = isl_set_is_wrapping(set);
+       isl_set_free(set);
+       if (ok < 0)
+               return -1;
+       if (!ok)
+               isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
+
+       return 0;
+}
+
+int test_equal(isl_ctx *ctx)
+{
+       const char *str;
+       isl_set *set, *set2;
+       int equal;
+
+       str = "{ S_6[i] }";
+       set = isl_set_read_from_str(ctx, str, -1);
+       str = "{ S_7[i] }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set, set2);
+       isl_set_free(set);
+       isl_set_free(set2);
+       if (equal < 0)
+               return -1;
+       if (equal)
+               isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
+
+       return 0;
+}
+
+static int test_plain_fixed(isl_ctx *ctx, __isl_take isl_map *map,
+       enum isl_dim_type type, unsigned pos, int fixed)
+{
+       int test;
+
+       test = isl_map_plain_is_fixed(map, type, pos, NULL);
+       isl_map_free(map);
+       if (test < 0)
+               return -1;
+       if (test == fixed)
+               return 0;
+       if (fixed)
+               isl_die(ctx, isl_error_unknown,
+                       "map not detected as fixed", return -1);
+       else
+               isl_die(ctx, isl_error_unknown,
+                       "map detected as fixed", return -1);
+}
+
+int test_fixed(isl_ctx *ctx)
+{
+       const char *str;
+       isl_map *map;
+
+       str = "{ [i] -> [i] }";
+       map = isl_map_read_from_str(ctx, str, -1);
+       if (test_plain_fixed(ctx, map, isl_dim_out, 0, 0))
+               return -1;
+       str = "{ [i] -> [1] }";
+       map = isl_map_read_from_str(ctx, str, -1);
+       if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
+               return -1;
+       str = "{ S_1[p1] -> [o0] : o0 = -2 and p1 >= 1 and p1 <= 7 }";
+       map = isl_map_read_from_str(ctx, str, -1);
+       if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
+               return -1;
+       map = isl_map_read_from_str(ctx, str, -1);
+       map = isl_map_neg(map);
+       if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
+               return -1;
+
+       return 0;
+}
+
 int main()
 {
        struct isl_ctx *ctx;
@@ -2353,6 +2465,12 @@ int main()
        assert(srcdir);
 
        ctx = isl_ctx_alloc();
+       if (test_fixed(ctx) < 0)
+               goto error;
+       if (test_equal(ctx) < 0)
+               goto error;
+       if (test_product(ctx) < 0)
+               goto error;
        if (test_dim_max(ctx) < 0)
                goto error;
        if (test_aff(ctx) < 0)