isl_tab_pip.c: set_row_cst_to_div: don't assume coefficient of div is zero
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 20 Oct 2011 18:18:57 +0000 (20:18 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 20 Oct 2011 18:22:15 +0000 (20:22 +0200)
The function is supposed to increment the coefficient of the given
div by one, but instead it would simply set the coefficient to one.
This is fine if the div is new and therefore has a zero coefficient,
but it does not work if the div already appeared in the constraint.

Reported-by: Armin Größlinger <armin.groesslinger@uni-passau.de>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_tab_pip.c
isl_test.c

index 9f9bdb1..8c0dedc 100644 (file)
@@ -859,7 +859,8 @@ static struct isl_tab *set_row_cst_to_div(struct isl_tab *tab, int row, int div)
        } else {
                int dcol = tab->var[tab->n_var - tab->n_div + div].index;
 
-               isl_int_set_si(tab->mat->row[row][2 + tab->M + dcol], 1);
+               isl_int_add_ui(tab->mat->row[row][2 + tab->M + dcol],
+                               tab->mat->row[row][2 + tab->M + dcol], 1);
        }
 
        return tab;
index 45f9572..eb8b151 100644 (file)
@@ -1353,6 +1353,15 @@ void test_lexmin(struct isl_ctx *ctx)
        assert(isl_map_is_equal(map, map2));
        isl_map_free(map);
        isl_map_free(map2);
+
+       str = "{ T[a] -> S[b, c] : a = 4b-2c and c >= b }";
+       map = isl_map_read_from_str(ctx, str);
+       map = isl_map_lexmin(map);
+       str = "{ T[a] -> S[b, c] : 2b = a and 2c = a }";
+       map2 = isl_map_read_from_str(ctx, str);
+       assert(isl_map_is_equal(map, map2));
+       isl_map_free(map);
+       isl_map_free(map2);
 }
 
 struct must_may {