From f574e2057abf385185242dee0c6278fd0ff04027 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 3 Jan 2009 11:21:23 +0100 Subject: [PATCH] isl_map_underlying_set: drop names from dimesion in underlying set When applying isl_mat transforamtions on sets, we currently assume that these sets have no names for the dimensions. --- include/isl_dim.h | 1 + isl_dim.c | 23 +++++++++++++++++++++++ isl_map.c | 17 ++++++++--------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/isl_dim.h b/include/isl_dim.h index 9a6529a..0d37b2a 100644 --- a/include/isl_dim.h +++ b/include/isl_dim.h @@ -54,6 +54,7 @@ struct isl_dim *isl_dim_drop_inputs(struct isl_dim *dim, struct isl_dim *isl_dim_drop_outputs(struct isl_dim *dim, unsigned first, unsigned n); struct isl_dim *isl_dim_domain(struct isl_dim *dim); +struct isl_dim *isl_dim_underlying(struct isl_dim *dim, unsigned n_div); int isl_dim_equal(struct isl_dim *dim1, struct isl_dim *dim2); int isl_dim_compatible(struct isl_dim *dim1, struct isl_dim *dim2); diff --git a/isl_dim.c b/isl_dim.c index 9ea54d7..61926ca 100644 --- a/isl_dim.c +++ b/isl_dim.c @@ -458,6 +458,29 @@ struct isl_dim *isl_dim_domain(struct isl_dim *dim) return isl_dim_reverse(dim); } +struct isl_dim *isl_dim_underlying(struct isl_dim *dim, unsigned n_div) +{ + int i; + + if (!dim) + return NULL; + if (n_div == 0 && + dim->nparam == 0 && dim->n_in == 0 && dim->n_name == 0) + return dim; + dim = isl_dim_cow(dim); + if (!dim) + return NULL; + dim->n_out += dim->nparam + dim->n_in + n_div; + dim->nparam = 0; + dim->n_in = 0; + + for (i = 0; i < dim->n_name; ++i) + isl_name_free(dim->ctx, get_name(dim, isl_dim_out, i)); + dim->n_name = 0; + + return dim; +} + unsigned isl_dim_total(struct isl_dim *dim) { return dim->nparam + dim->n_in + dim->n_out; diff --git a/isl_map.c b/isl_map.c index e05cc54..9248537 100644 --- a/isl_map.c +++ b/isl_map.c @@ -1925,12 +1925,9 @@ struct isl_basic_set *isl_basic_map_underlying_set( bmap = isl_basic_map_cow(bmap); if (!bmap) goto error; - bmap->dim = isl_dim_cow(bmap->dim); + bmap->dim = isl_dim_underlying(bmap->dim, bmap->n_div); if (!bmap->dim) goto error; - bmap->dim->n_out += bmap->dim->nparam + bmap->dim->n_in + bmap->n_div; - bmap->dim->nparam = 0; - bmap->dim->n_in = 0; bmap->extra -= bmap->n_div; bmap->n_div = 0; bmap = isl_basic_map_finalize(bmap); @@ -2066,11 +2063,13 @@ struct isl_set *isl_map_underlying_set(struct isl_map *map) goto error; } if (map->n == 0) - map->dim->n_out += map->dim->nparam + map->dim->n_in; - else - map->dim->n_out = map->p[0]->dim->n_out; - map->dim->nparam = 0; - map->dim->n_in = 0; + map->dim = isl_dim_underlying(map->dim, 0); + else { + isl_dim_free(map->dim); + map->dim = isl_dim_copy(map->p[0]->dim); + } + if (!map->dim) + goto error; return (struct isl_set *)map; error: isl_map_free(map); -- 2.7.4