From e2f596c4d38074b5461205f0f3c93627f182fccc Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 22 Jun 2020 14:55:39 +0200 Subject: [PATCH] clear ISL_BASIC_MAP_REDUCED_COEFFICIENTS when needed That is, clear the flag when the coefficients (other than the constant term) of an inequality constraint may get modified or when a new inequality constraint is added. Do so instead of clearing the flag every time the basic map is changed in any way or when some progress is made during simplification. This should more accurately reflect when the coefficients may no longer be reduced and is more in line with how the other flags are handled. One case that was missed before in particular was the call to isl_basic_map_gauss from within isl_basic_map_reduce_coefficients itself. It this call takes place, then the coefficients may very well no longer be reduced, as evidenced by an upcoming commit. Note that accurately keeping track of this flag is not all that important. Since isl_basic_map_reduce_coefficients may leave the output in an inconsistent state, it always needs to be followed by a call to isl_basic_map_gauss, which would typically remove the flag. The chance that the flag is still set on the next call to isl_basic_map_reduce_coefficients is therefore very small. Signed-off-by: Sven Verdoolaege --- isl_map.c | 7 ++++--- isl_map_simplify.c | 3 +-- isl_mat.c | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/isl_map.c b/isl_map.c index 53a0af93..665c2600 100644 --- a/isl_map.c +++ b/isl_map.c @@ -1752,6 +1752,7 @@ int isl_basic_map_alloc_inequality(__isl_keep isl_basic_map *bmap) ISL_F_CLR(bmap, ISL_BASIC_MAP_NO_REDUNDANT); ISL_F_CLR(bmap, ISL_BASIC_MAP_SORTED); ISL_F_CLR(bmap, ISL_BASIC_MAP_ALL_EQUALITIES); + ISL_F_CLR(bmap, ISL_BASIC_MAP_REDUCED_COEFFICIENTS); isl_seq_clr(bmap->ineq[bmap->n_ineq] + 1 + total, bmap->extra - bmap->n_div); return bmap->n_ineq++; @@ -2057,10 +2058,8 @@ __isl_give isl_basic_map *isl_basic_map_cow(__isl_take isl_basic_map *bmap) bmap->ref--; bmap = isl_basic_map_dup(bmap); } - if (bmap) { + if (bmap) ISL_F_CLR(bmap, ISL_BASIC_SET_FINAL); - ISL_F_CLR(bmap, ISL_BASIC_MAP_REDUCED_COEFFICIENTS); - } return bmap; } @@ -2423,6 +2422,7 @@ __isl_give isl_basic_map *isl_basic_map_drop_core( ISL_F_CLR(bmap, ISL_BASIC_MAP_NO_REDUNDANT); ISL_F_CLR(bmap, ISL_BASIC_MAP_SORTED); + ISL_F_CLR(bmap, ISL_BASIC_MAP_REDUCED_COEFFICIENTS); return bmap; } @@ -14671,6 +14671,7 @@ __isl_give isl_basic_map *isl_basic_map_transform_dims( ISL_F_CLR(bmap, ISL_BASIC_MAP_SORTED); ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED_DIVS); + ISL_F_CLR(bmap, ISL_BASIC_MAP_REDUCED_COEFFICIENTS); isl_mat_free(trans); return bmap; diff --git a/isl_map_simplify.c b/isl_map_simplify.c index 72e0e9bb..780b03ce 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -332,6 +332,7 @@ static __isl_give isl_basic_map *eliminate_var_using_equality( isl_seq_normalize(bmap->ctx, bmap->ineq[k], 1 + total); ISL_F_CLR(bmap, ISL_BASIC_MAP_NO_REDUNDANT); ISL_F_CLR(bmap, ISL_BASIC_MAP_SORTED); + ISL_F_CLR(bmap, ISL_BASIC_MAP_REDUCED_COEFFICIENTS); } for (k = 0; k < bmap->n_div; ++k) { @@ -1539,8 +1540,6 @@ __isl_give isl_basic_map *isl_basic_map_simplify(__isl_take isl_basic_map *bmap) bmap = normalize_divs(bmap, &progress); bmap = isl_basic_map_remove_duplicate_constraints(bmap, &progress, 1); - if (bmap && progress) - ISL_F_CLR(bmap, ISL_BASIC_MAP_REDUCED_COEFFICIENTS); } return bmap; } diff --git a/isl_mat.c b/isl_mat.c index 37468ee3..5ec99b5a 100644 --- a/isl_mat.c +++ b/isl_mat.c @@ -1401,6 +1401,7 @@ __isl_give isl_basic_set *isl_basic_set_preimage( ISL_F_CLR(bset, ISL_BASIC_SET_SORTED); ISL_F_CLR(bset, ISL_BASIC_SET_NORMALIZED_DIVS); ISL_F_CLR(bset, ISL_BASIC_SET_ALL_EQUALITIES); + ISL_F_CLR(bset, ISL_BASIC_SET_REDUCED_COEFFICIENTS); bset = isl_basic_set_simplify(bset); bset = isl_basic_set_finalize(bset); -- 2.11.4.GIT