isl_map_coalesce: avoid reconsidering pairs considered before on change
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 2 Apr 2010 20:45:57 +0000 (22:45 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 2 Apr 2010 20:45:57 +0000 (22:45 +0200)
Before, whenever anything changed (two elements get fused or one
element gets dropped), we would start all over from scratch.
Pairs that were already considered before and that are not related
to the change do not need to be reconsidered.
We may still reconsider some pairs, even after this commit.
In particular, if one element gets dropped, then we will still reconsider
all combinations with the element that did not get dropped.

isl_coalesce.c

index f5f637c..6234924 100644 (file)
@@ -844,14 +844,15 @@ static struct isl_map *coalesce(struct isl_map *map, struct isl_tab **tabs)
 {
        int i, j;
 
-       for (i = 0; i < map->n - 1; ++i)
+       for (i = map->n - 2; i >= 0; --i)
+restart:
                for (j = i + 1; j < map->n; ++j) {
                        int changed;
                        changed = coalesce_pair(map, i, j, tabs);
                        if (changed < 0)
                                goto error;
                        if (changed)
-                               return coalesce(map, tabs);
+                               goto restart;
                }
        return map;
 error: