From 9fa4930d95e75c4ad1fa3672b64a567d0b297db7 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 10 Mar 2009 13:45:31 +0100 Subject: [PATCH] isl_map_affine_hull: detect equalities of integer affine hull before cowing --- include/isl_map.h | 1 + isl_affine_hull.c | 55 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/isl_map.h b/include/isl_map.h index 6615dd2..42069ae 100644 --- a/include/isl_map.h +++ b/include/isl_map.h @@ -239,6 +239,7 @@ struct isl_map *isl_map_fix_si(struct isl_map *map, struct isl_basic_set *isl_basic_map_deltas(struct isl_basic_map *bmap); struct isl_set *isl_map_deltas(struct isl_map *map); struct isl_set *isl_map_range(struct isl_map *map); +struct isl_map *isl_map_detect_equalities(struct isl_map *map); struct isl_basic_map *isl_map_affine_hull(struct isl_map *map); struct isl_map *isl_map_remove(struct isl_map *map, enum isl_dim_type type, unsigned first, unsigned n); diff --git a/isl_affine_hull.c b/isl_affine_hull.c index e3794d1..746a34e 100644 --- a/isl_affine_hull.c +++ b/isl_affine_hull.c @@ -394,6 +394,29 @@ error: return NULL; } +struct isl_map *isl_map_detect_equalities(struct isl_map *map) +{ + struct isl_basic_map *bmap; + int i; + + if (!map) + return NULL; + + for (i = 0; i < map->n; ++i) { + bmap = isl_basic_map_copy(map->p[i]); + bmap = isl_basic_map_detect_equalities(bmap); + if (!bmap) + goto error; + isl_basic_map_free(map->p[i]); + map->p[i] = bmap; + } + + return map; +error: + isl_map_free(map); + return NULL; +} + /* After computing the rational affine hull (by detecting the implicit * equalities), we compute the additional equalities satisfied by * the integer points (if any) and add the original equalities back in. @@ -402,35 +425,10 @@ struct isl_basic_map *isl_basic_map_affine_hull(struct isl_basic_map *bmap) { struct isl_basic_set *hull = NULL; - bmap = isl_basic_map_implicit_equalities(bmap); - if (!bmap) - return NULL; - if (bmap->n_ineq == 0) - return bmap; - - if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL)) { - bmap = isl_basic_map_cow(bmap); - isl_basic_map_free_inequality(bmap, bmap->n_ineq); - return bmap; - } - - hull = equalities_in_underlying_set(isl_basic_map_copy(bmap)); - if (!hull) - goto error; - + bmap = isl_basic_map_detect_equalities(bmap); bmap = isl_basic_map_cow(bmap); - if (!bmap) - goto error; isl_basic_map_free_inequality(bmap, bmap->n_ineq); - bmap = isl_basic_map_intersect(bmap, - isl_basic_map_overlying_set(hull, - isl_basic_map_copy(bmap))); - - return isl_basic_map_finalize(bmap); -error: - isl_basic_set_free(hull); - isl_basic_map_free(bmap); - return NULL; + return bmap; } struct isl_basic_set *isl_basic_set_affine_hull(struct isl_basic_set *bset) @@ -455,7 +453,10 @@ struct isl_basic_map *isl_map_affine_hull(struct isl_map *map) return hull; } + map = isl_map_detect_equalities(map); map = isl_map_align_divs(map); + if (!map) + return NULL; model = isl_basic_map_copy(map->p[0]); set = isl_map_underlying_set(map); set = isl_set_cow(set); -- 2.7.4