From c6d0c8c0848f14fa66040286491550e50afa4d9d Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 20 Jun 2015 18:34:41 +0200 Subject: [PATCH] isl_basic_map_gist: only take into account equalities in input and context In particular, do not take into account additional equalities in the intersection of input and context for computing a compression. While taking into account such additional equalities can result in extra equalities getting detected in the gist, it also makes it impossible or at least difficult to avoid introducing constraints in the gist on variables that do not appear in the input. Introducing such constraints is not only counterintuitive, it also breaks an assumption in the AST generator that the result of the gist will not involve any loop iterators that did not already appear in the input. Signed-off-by: Sven Verdoolaege --- isl_map_simplify.c | 13 +++++++++---- isl_test.c | 11 ++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/isl_map_simplify.c b/isl_map_simplify.c index 00beb01d..f108157a 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -2602,8 +2602,9 @@ error: * that are irrelevant for computing the gist of "bset". * Alternatively, we could factorize the intersection of "context" and "bset". * - * We first compute the integer affine hull of the intersection, - * compute the gist inside this affine hull and then add back + * We first compute the intersection of the integer affine hulls + * of "bset" and "context", + * compute the gist inside this intersection and then add back * those equalities that are not implied by the context. * * If two constraints are mutually redundant, then uset_gist_full @@ -2627,9 +2628,13 @@ static __isl_give isl_basic_set *uset_gist(__isl_take isl_basic_set *bset, context = drop_irrelevant_constraints(context, bset); + bset = isl_basic_set_detect_equalities(bset); aff = isl_basic_set_copy(bset); - aff = isl_basic_set_intersect(aff, isl_basic_set_copy(context)); - aff = isl_basic_set_affine_hull(aff); + aff = isl_basic_set_plain_affine_hull(aff); + context = isl_basic_set_detect_equalities(context); + aff_context = isl_basic_set_copy(context); + aff_context = isl_basic_set_plain_affine_hull(aff_context); + aff = isl_basic_set_intersect(aff, aff_context); if (!aff) goto error; if (isl_basic_set_plain_is_empty(aff)) { diff --git a/isl_test.c b/isl_test.c index 173634e5..f7e6791d 100644 --- a/isl_test.c +++ b/isl_test.c @@ -1279,9 +1279,18 @@ struct { "{ [m, n, ku, kl] }" }, { "{ [a, a, b] : a >= 10 }", "{ [a, b, c] : c >= a and c <= b and c >= 2 }", - "{ [a, a, a] : a >= 10 }" }, + "{ [a, a, b] : a >= 10 }" }, { "{ [i, j] : i >= 0 and i + j >= 0 }", "{ [i, j] : i <= 0 }", "{ [0, j] : j >= 0 }" }, + /* Check that no constraints on i6 are introduced in the gist */ + { "[t1] -> { [i4, i6] : exists (e0 = floor((1530 - 4t1 - 5i4)/20): " + "20e0 <= 1530 - 4t1 - 5i4 and 20e0 >= 1511 - 4t1 - 5i4 and " + "5e0 <= 381 - t1 and i4 <= 1) }", + "[t1] -> { [i4, i6] : exists (e0 = floor((-t1 + i6)/5): " + "5e0 = -t1 + i6 and i6 <= 6 and i6 >= 3) }", + "[t1] -> { [i4, i6] : exists (e0 = floor((1530 - 4t1 - 5i4)/20): " + "i4 <= 1 and 5e0 <= 381 - t1 and 20e0 <= 1530 - 4t1 - 5i4 and " + "20e0 >= 1511 - 4t1 - 5i4) }" }, }; static int test_gist(struct isl_ctx *ctx) -- 2.11.4.GIT