isl_map_coalesce: allowing cutting equalities in adjacent facet
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 18 Apr 2010 16:37:56 +0000 (18:37 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 23 Apr 2010 10:48:08 +0000 (12:48 +0200)
From the start, we have been very careful not to allow any cutting
equalities anywhere.  However, it makes sense to wrap in a piece
of a hyperplane adjacent to a facet, even if this piece is
lower-dimensional.

isl_coalesce.c
isl_test.c

index c339d0d..a55b656 100644 (file)
@@ -696,7 +696,7 @@ static int check_wrap(struct isl_map *map, int i, int j,
  * inequality adjacent to an equality.
  * We call the basic map that has the inequality "i" and the basic
  * map that has the equality "j".
- * If "i" has any "cut" inequality, then relaxing the inequality
+ * If "i" has any "cut" (in)equality, then relaxing the inequality
  * by one would not result in a basic map that contains the other
  * basic map.
  */
@@ -717,6 +717,8 @@ static int check_adj_eq(struct isl_map *map, int i, int j,
 
        /* j has an equality adjacent to an inequality in i */
 
+       if (any(eq_i, 2 * map->p[i]->n_eq, STATUS_CUT))
+               return 0;
        if (any(ineq_i, map->p[i]->n_ineq, STATUS_CUT))
                /* ADJ EQ CUT */
                return 0;
@@ -850,9 +852,6 @@ static int coalesce_pair(struct isl_map *map, int i, int j,
                   all(ineq_j, map->p[j]->n_ineq, STATUS_VALID)) {
                drop(map, i, tabs);
                changed = 1;
-       } else if (any(eq_i, 2 * map->p[i]->n_eq, STATUS_CUT) ||
-                  any(eq_j, 2 * map->p[j]->n_eq, STATUS_CUT)) {
-               /* BAD CUT */
        } else if (any(eq_i, 2 * map->p[i]->n_eq, STATUS_ADJ_EQ) ||
                   any(eq_j, 2 * map->p[j]->n_eq, STATUS_ADJ_EQ)) {
                /* ADJ EQ PAIR */
@@ -860,6 +859,9 @@ static int coalesce_pair(struct isl_map *map, int i, int j,
                   any(eq_j, 2 * map->p[j]->n_eq, STATUS_ADJ_INEQ)) {
                changed = check_adj_eq(map, i, j, tabs,
                                        eq_i, ineq_i, eq_j, ineq_j);
+       } else if (any(eq_i, 2 * map->p[i]->n_eq, STATUS_CUT) ||
+                  any(eq_j, 2 * map->p[j]->n_eq, STATUS_CUT)) {
+               /* BAD CUT */
        } else if (any(ineq_i, map->p[i]->n_ineq, STATUS_ADJ_EQ) ||
                   any(ineq_j, map->p[j]->n_ineq, STATUS_ADJ_EQ)) {
                /* Can't happen */
index 7e15ffd..ec5570b 100644 (file)
@@ -776,6 +776,9 @@ void test_coalesce(struct isl_ctx *ctx)
                                "(i1 = M and M >= 1) }", 0);
        test_coalesce_set(ctx,
                "{[x,y] : x,y >= 0; [x,y] : 10 <= x <= 20 and y >= -1 }", 0);
+       test_coalesce_set(ctx,
+               "{ [x, y] : (x >= 1 and y >= 1 and x <= 2 and y <= 2) or "
+               "(y = 3 and x = 1) }", 1);
 }
 
 void test_closure(struct isl_ctx *ctx)