From 1f7617a9257b6afae391aae7172b9cb8873f9bb6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 10 Mar 2009 10:51:09 +0100 Subject: [PATCH] isl_basic_map_extend_dim: only extend constraint matrix if needed --- isl_map.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/isl_map.c b/isl_map.c index cba9f28..bb49e87 100644 --- a/isl_map.c +++ b/isl_map.c @@ -451,13 +451,18 @@ void isl_basic_set_free(struct isl_basic_set *bset) isl_basic_map_free((struct isl_basic_map *)bset); } +static int room_for_con(struct isl_basic_map *bmap, unsigned n) +{ + return bmap->n_eq + bmap->n_ineq + n <= bmap->c_size; +} + int isl_basic_map_alloc_equality(struct isl_basic_map *bmap) { struct isl_ctx *ctx; if (!bmap) return -1; ctx = bmap->ctx; - isl_assert(ctx, bmap->n_eq + bmap->n_ineq < bmap->c_size, return -1); + isl_assert(ctx, room_for_con(bmap, 1), return -1); isl_assert(ctx, (bmap->eq - bmap->ineq) + bmap->n_eq <= bmap->c_size, return -1); ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED_DIVS); @@ -532,13 +537,18 @@ void isl_basic_map_inequality_to_equality( ISL_F_CLR(bmap, ISL_BASIC_MAP_ALL_EQUALITIES); } +static int room_for_ineq(struct isl_basic_map *bmap, unsigned n) +{ + return bmap->n_ineq + n <= bmap->eq - bmap->ineq; +} + int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap) { struct isl_ctx *ctx; if (!bmap) return -1; ctx = bmap->ctx; - isl_assert(ctx, bmap->n_ineq < bmap->eq - bmap->ineq, return -1); + isl_assert(ctx, room_for_ineq(bmap, 1), return -1); ISL_F_CLR(bmap, ISL_BASIC_MAP_NO_IMPLICIT); ISL_F_CLR(bmap, ISL_BASIC_MAP_NO_REDUNDANT); ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED); @@ -794,7 +804,8 @@ struct isl_basic_map *isl_basic_map_extend_dim(struct isl_basic_map *base, dims_ok = isl_dim_equal(base->dim, dim) && base->extra >= base->n_div + extra; - if (dims_ok && n_eq == 0 && n_ineq == 0) { + if (dims_ok && room_for_con(base, n_eq + n_ineq) && + room_for_ineq(base, n_ineq)) { isl_dim_free(dim); return base; } -- 2.7.4