From 2fadd1c821c5123f9dec380d65ade74bbbd937ee Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 13 Feb 2020 16:12:04 +0100 Subject: [PATCH] isl_map_coalesce: eliminate unit divs from wrapping constraints This fixes a regression introduced in isl-0.18-43-g0b4256f662 (isl_map_coalesce: harmonize integer divisions in stride constraints, Tue Oct 4 11:12:34 2016 +0200) in the sense that the newly added test case would get coalesced before that commit, but not after that commit. The reason is that before that commit, the two disjuncts with (different) integer divisions would get coalesced first. Since the integer division expressions are not identical, an unknown local variable would get added inside fuse and an attempt would be made to recover an integer division expression by simplifying the result. The simplification would also result in the elimination of all appearances of the integer division with a unit coefficient. If this integer division does not appear with any other coefficient in any other constraint, then it would get eliminated completely. Since the above commit, the integer divisions get harmonized first, meaning that they are the same when the disjuncts get fused and no simplification is performed. The remaining disjunct is then seen as having a separating constraint. Explicitly eliminate (pure) unit integer divisions from extra (wrapping) constraints if no complete simplification is being performed to recover the effect on these unit integer divisions. Signed-off-by: Sven Verdoolaege --- isl_coalesce.c | 7 +++++++ isl_test.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/isl_coalesce.c b/isl_coalesce.c index b494c2dc..00a3ca8b 100644 --- a/isl_coalesce.c +++ b/isl_coalesce.c @@ -500,6 +500,11 @@ static int number_of_constraints_increases(int i, int j, * the same as that of the other basic map. Otherwise, we mark * the integer division as unknown and simplify the basic map * in an attempt to recover the integer division definition. + * If any extra constraints get introduced, then these may + * involve integer divisions with a unit coefficient. + * Eliminate those that do not appear with any other coefficient + * in other constraints, to ensure they get eliminated completely, + * improving the chances of further coalescing. */ static enum isl_change fuse(int i, int j, struct isl_coalesce_info *info, __isl_keep isl_mat *extra, int detect_equalities, int check_number) @@ -556,6 +561,8 @@ static enum isl_change fuse(int i, int j, struct isl_coalesce_info *info, if (simplify || info[j].simplify) { fused = isl_basic_map_simplify(fused); info[i].simplify = 0; + } else if (extra_rows > 0) { + fused = isl_basic_map_eliminate_pure_unit_divs(fused); } fused = isl_basic_map_finalize(fused); diff --git a/isl_test.c b/isl_test.c index 16faf73b..0ed83137 100644 --- a/isl_test.c +++ b/isl_test.c @@ -2378,6 +2378,8 @@ struct { { 0, "{ [j, a, l] : a mod 2 = 0 and j <= 29 and a >= 2 and " "2a <= -5 + j and 32j + 2a + 2 <= 4l < 33j; " "[j, 0, l] : 4 <= j <= 29 and -3 + 33j <= 4l <= 33j }" }, + { 1, "{ [a] : (a = 0 or ((1 + a) mod 2 = 0 and 0 < a <= 15) or " + "((a) mod 2 = 0 and 0 < a <= 15)) }" }, }; /* A specialized coalescing test case that would result -- 2.11.4.GIT