From be518dd6c898e3f72d6e62aff2485bf6b68dbc38 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 28 Apr 2010 23:45:49 +0200 Subject: [PATCH] isl_map_transitive_closure: check if input is closed already --- isl_transitive_closure.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/isl_transitive_closure.c b/isl_transitive_closure.c index 4767040e..5d6c9947 100644 --- a/isl_transitive_closure.c +++ b/isl_transitive_closure.c @@ -2387,6 +2387,18 @@ error: return NULL; } +int isl_map_is_transitively_closed(__isl_keep isl_map *map) +{ + isl_map *map2; + int closed; + + map2 = isl_map_apply_range(isl_map_copy(map), isl_map_copy(map)); + closed = isl_map_is_subset(map2, map); + isl_map_free(map2); + + return closed; +} + /* Compute the transitive closure of "map", or an overapproximation. * If the result is exact, then *exact is set to 1. * Simply use map_power to compute the powers of map, but tell @@ -2397,6 +2409,7 @@ __isl_give isl_map *isl_map_transitive_closure(__isl_take isl_map *map, int *exact) { unsigned param; + int closed; if (!map) goto error; @@ -2404,6 +2417,15 @@ __isl_give isl_map *isl_map_transitive_closure(__isl_take isl_map *map, if (map->ctx->opt->closure == ISL_CLOSURE_OMEGA) return transitive_closure_omega(map, exact); + closed = isl_map_is_transitively_closed(map); + if (closed < 0) + goto error; + if (closed) { + if (exact) + *exact = 1; + return map; + } + param = isl_map_dim(map, isl_dim_param); map = map_power(map, param, exact, 1); -- 2.11.4.GIT