isl_tab_min_at_most_neg_one: restore sample value of non-redundant constraints
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 2 Apr 2010 20:59:43 +0000 (22:59 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 2 Apr 2010 21:00:19 +0000 (23:00 +0200)
isl_tab.c
isl_test.c

index da64453..8acd40a 100644 (file)
--- a/isl_tab.c
+++ b/isl_tab.c
@@ -1361,7 +1361,8 @@ static int row_at_most_neg_one(struct isl_tab *tab, int row)
  * Return 0 otherwise.
  *
  * The sample value of "var" is assumed to be non-negative when the
- * the function is called and will be made non-negative again before
+ * the function is called.  If 1 is returned then the constraint
+ * is not redundant and the sample value is made non-negative again before
  * the function returns.
  */
 int isl_tab_min_at_most_neg_one(struct isl_tab *tab, struct isl_tab_var *var)
@@ -1396,8 +1397,11 @@ int isl_tab_min_at_most_neg_one(struct isl_tab *tab, struct isl_tab_var *var)
                return 0;
        do {
                find_pivot(tab, var, var, -1, &row, &col);
-               if (row == var->index)
+               if (row == var->index) {
+                       if (restore_row(tab, var) < -1)
+                               return -1;
                        return 1;
+               }
                if (row == -1)
                        return 0;
                pivot_var = var_from_col(tab, col);
index 70bcfc2..a9f3377 100644 (file)
@@ -692,6 +692,28 @@ void test_coalesce(struct isl_ctx *ctx)
        assert(isl_map_is_equal(map, map2));
        isl_map_free(map);
        isl_map_free(map2);
+
+       str = "[M, N] -> { [i0, i1, i2, i3, i4, i5, i6] -> "
+         "[o0, o1, o2, o3, o4, o5, o6] : "
+         "(o6 <= -4 + 2M - 2N + i0 + i1 - i2 + i6 - o0 - o1 + o2 and "
+         "o3 <= -2 + i3 and o6 >= 2 + i0 + i3 + i6 - o0 - o3 and "
+         "o6 >= 2 - M + N + i3 + i4 + i6 - o3 - o4 and o0 <= -1 + i0 and "
+         "o4 >= 4 - 3M + 3N - i0 - i1 + i2 + 2i3 + i4 + o0 + o1 - o2 - 2o3 "
+         "and o6 <= -3 + 2M - 2N + i3 + i4 - i5 + i6 - o3 - o4 + o5 and "
+         "2o6 <= -5 + 5M - 5N + 2i0 + i1 - i2 - i5 + 2i6 - 2o0 - o1 + o2 + o5 "
+         "and o6 >= 2i0 + i1 + i6 - 2o0 - o1 and "
+         "3o6 <= -5 + 4M - 4N + 2i0 + i1 - i2 + 2i3 + i4 - i5 + 3i6 "
+         "- 2o0 - o1 + o2 - 2o3 - o4 + o5) or "
+         "(N >= 2 and o3 <= -1 + i3 and o0 <= -1 + i0 and "
+         "o6 >= i3 + i6 - o3 and M >= 0 and "
+         "2o6 >= 1 + i0 + i3 + 2i6 - o0 - o3 and "
+         "o6 >= 1 - M + i0 + i6 - o0 and N >= 2M and o6 >= i0 + i6 - o0) }";
+       map = isl_map_read_from_str(ctx, str, -1);
+       map = isl_map_coalesce(map);
+       map2 = isl_map_read_from_str(ctx, str, -1);
+       assert(isl_map_is_equal(map, map2));
+       isl_map_free(map);
+       isl_map_free(map2);
 }
 
 void test_closure(struct isl_ctx *ctx)