isl_map_coalesce: be more relaxed about multiple equalities being adjacent
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 19 Feb 2011 17:35:24 +0000 (18:35 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 19 Feb 2011 19:25:37 +0000 (20:25 +0100)
We try to avoid wrapping in a basic map that has multiple equalities
that are adjacent to inequalities in the other basic map, because that
may lead to more complicated constraints.
The original check would, however, also prevent the extension of
one basic map with an other if they happened to lie in a shared
affine subspace.  By moving the test for multiple equalities after
the check for extensions, we allow such extensions, while still
preventing undesired wrapping.

We can probably do better by explicitly detecting and exploiting
the shared affine subspace.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_coalesce.c
isl_test.c

index 22524aa..a07d983 100644 (file)
@@ -916,8 +916,7 @@ static int check_adj_eq(struct isl_map *map, int i, int j,
        if (any(ineq_i, map->p[i]->n_ineq, STATUS_CUT))
                /* ADJ EQ CUT */
                return 0;
-       if (count(eq_j, 2 * map->p[j]->n_eq, STATUS_ADJ_INEQ) != 1 ||
-           count(ineq_i, map->p[i]->n_ineq, STATUS_ADJ_EQ) != 1 ||
+       if (count(ineq_i, map->p[i]->n_ineq, STATUS_ADJ_EQ) != 1 ||
            any(ineq_j, map->p[j]->n_ineq, STATUS_ADJ_EQ) ||
            any(ineq_i, map->p[i]->n_ineq, STATUS_ADJ_INEQ) ||
            any(ineq_j, map->p[j]->n_ineq, STATUS_ADJ_INEQ))
@@ -932,6 +931,9 @@ static int check_adj_eq(struct isl_map *map, int i, int j,
        if (changed)
                return changed;
 
+       if (count(eq_j, 2 * map->p[j]->n_eq, STATUS_ADJ_INEQ) != 1)
+               return 0;
+
        changed = can_wrap_in_facet(map, i, j, k, tabs, eq_i, ineq_i, eq_j, ineq_j);
 
        return changed;
index 2f19799..6116e3a 100644 (file)
@@ -906,6 +906,8 @@ void test_coalesce(struct isl_ctx *ctx)
        test_coalesce_set(ctx,
                "{[x,0,0] : -5 <= x <= 5; [0,y,1] : -5 <= y <= 5 }", 1);
        test_coalesce_set(ctx, "{ [x, 1 - x] : 0 <= x <= 1; [0,0] }", 1);
+       test_coalesce_set(ctx, "{ [0,0]; [i,i] : 1 <= i <= 10 }", 1);
+       test_coalesce_set(ctx, "{ [0,0]; [i,j] : 1 <= i,j <= 10 }", 0);
 }
 
 void test_closure(struct isl_ctx *ctx)