isl_map_is_subset: a map cannot be as subset of a map in a different space
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 10 Aug 2011 08:17:54 +0000 (10:17 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 10 Aug 2011 10:10:27 +0000 (12:10 +0200)
The only debatable case is that of an empty map, which in principle
could be considered to be a subset of any map.  This patch considers
empty maps not to be subsets of maps in other spaces.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map_subtract.c
isl_test.c

index 0510657..08177e7 100644 (file)
@@ -709,6 +709,9 @@ int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2)
        if (!map1 || !map2)
                return -1;
 
+       if (!isl_map_has_equal_dim(map1, map2))
+               return 0;
+
        if (isl_map_is_empty(map1))
                return 1;
 
index 4d1bfd1..de558b9 100644 (file)
@@ -2356,6 +2356,27 @@ int test_product(isl_ctx *ctx)
        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;
+}
+
 int main()
 {
        struct isl_ctx *ctx;
@@ -2364,6 +2385,8 @@ int main()
        assert(srcdir);
 
        ctx = isl_ctx_alloc();
+       if (test_equal(ctx) < 0)
+               goto error;
        if (test_product(ctx) < 0)
                goto error;
        if (test_dim_max(ctx) < 0)