From: Sven Verdoolaege Date: Fri, 14 Sep 2012 08:15:55 +0000 (+0200) Subject: isl_map_union: special case universal input X-Git-Tag: isl-0.11~168 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=796b9432549c01b63e9d159edab58ede8440229e;p=platform%2Fupstream%2Fisl.git 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 --- 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) &&