isl_map_intersect: be careful when intersecting with empty parameter domain
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 25 Jul 2011 15:17:12 +0000 (17:17 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 25 Jul 2011 15:17:12 +0000 (17:17 +0200)
isl_map_intersect currently doubles as a isl_map_intersect_params
and in this capacity, the spaces of the two arguments may be different.
In this case, we need to make sure that we return an (empty) map
in the correct space.

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

index 8ed3e44..9171576 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -2412,11 +2412,13 @@ static __isl_give isl_map *map_intersect(__isl_take isl_map *map1,
        if (!map1 || !map2)
                goto error;
 
-       if (isl_map_plain_is_empty(map1)) {
+       if (isl_map_plain_is_empty(map1) &&
+           isl_dim_equal(map1->dim, map2->dim)) {
                isl_map_free(map2);
                return map1;
        }
-       if (isl_map_plain_is_empty(map2)) {
+       if (isl_map_plain_is_empty(map2) &&
+           isl_dim_equal(map1->dim, map2->dim)) {
                isl_map_free(map1);
                return map2;
        }