From 24747623828aae63d287a3184640ef57615a01c6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 5 Apr 2010 19:57:27 +0200 Subject: [PATCH] isl_map_intersect: add special cases for empty input maps In particular, if both input maps consist of a single basic map and that of the first map turns out to be empty, then we need to take into account that after cowing the map, it may not have any basic maps anymore. --- isl_map.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/isl_map.c b/isl_map.c index 491287a..2992282 100644 --- a/isl_map.c +++ b/isl_map.c @@ -1882,6 +1882,10 @@ static __isl_give isl_map *map_intersect_add_constraint( map1 = isl_map_cow(map1); if (!map1) goto error; + if (isl_map_fast_is_empty(map1)) { + isl_map_free(map2); + return map1; + } map1->p[0] = isl_basic_map_cow(map1->p[0]); if (map2->p[0]->n_eq == 1) map1->p[0] = isl_basic_map_add_eq(map1->p[0], map2->p[0]->eq[0]); @@ -1917,6 +1921,15 @@ struct isl_map *isl_map_intersect(struct isl_map *map1, struct isl_map *map2) if (!map1 || !map2) goto error; + if (isl_map_fast_is_empty(map1)) { + isl_map_free(map2); + return map1; + } + if (isl_map_fast_is_empty(map2)) { + isl_map_free(map1); + return map2; + } + if (map1->n == 1 && map2->n == 1 && map1->p[0]->n_div == 0 && map2->p[0]->n_div == 0 && isl_dim_equal(map1->dim, map2->dim) && -- 2.7.4