From 0c49639375e79641e9ffc0b972584e2820da587d Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 10 Aug 2011 10:17:54 +0200 Subject: [PATCH] isl_map_is_subset: a map cannot be as subset of a map in a different space 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 --- isl_map_subtract.c | 3 +++ isl_test.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/isl_map_subtract.c b/isl_map_subtract.c index 0510657..08177e7 100644 --- a/isl_map_subtract.c +++ b/isl_map_subtract.c @@ -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; diff --git a/isl_test.c b/isl_test.c index 4d1bfd1..de558b9 100644 --- a/isl_test.c +++ b/isl_test.c @@ -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) -- 2.7.4