From 796b9432549c01b63e9d159edab58ede8440229e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 14 Sep 2012 10:15:55 +0200 Subject: [PATCH] isl_map_union: special case universal input In particular, there is no need to construct a new isl_map as we can simply return the universal input map. Signed-off-by: Sven Verdoolaege --- isl_map.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/isl_map.c b/isl_map.c index c83a446..3ef86f4 100644 --- a/isl_map.c +++ b/isl_map.c @@ -6446,12 +6446,23 @@ error: return NULL; } +/* Return the union of "map1" and "map2", where we assume for now that + * "map1" and "map2" are disjoint. Note that the basic maps inside + * "map1" or "map2" may not be disjoint from each other. + * Also note that this function is also called from isl_map_union, + * which takes care of handling the situation where "map1" and "map2" + * may not be disjoint. + * + * If one of the inputs is empty, we can simply return the other input. + * Similarly, if one of the inputs is universal, then it is equal to the union. + */ static __isl_give isl_map *map_union_disjoint(__isl_take isl_map *map1, __isl_take isl_map *map2) { int i; unsigned flags = 0; struct isl_map *map = NULL; + int is_universe; if (!map1 || !map2) goto error; @@ -6465,6 +6476,22 @@ static __isl_give isl_map *map_union_disjoint(__isl_take isl_map *map1, return map1; } + is_universe = isl_map_plain_is_universe(map1); + if (is_universe < 0) + goto error; + if (is_universe) { + isl_map_free(map2); + return map1; + } + + is_universe = isl_map_plain_is_universe(map2); + if (is_universe < 0) + goto error; + if (is_universe) { + isl_map_free(map1); + return map2; + } + isl_assert(map1->ctx, isl_space_is_equal(map1->dim, map2->dim), goto error); if (ISL_F_ISSET(map1, ISL_MAP_DISJOINT) && -- 2.7.4