From c9c4f446e9f40d07f76235d81c2b250e4ef94bd8 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 27 Jan 2009 10:48:32 +0100 Subject: [PATCH] isl_map_simplify.c: normalize_divs: fix use of variable compression When there is a div that depends on another div, then we need to be careful not to look for the other div in the variable compression matrix. --- isl_map_simplify.c | 5 +++-- isl_test.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/isl_map_simplify.c b/isl_map_simplify.c index b6d891a..b1f874e 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -629,7 +629,8 @@ out: * x'' = T(x') = x_0 + G x' * * and in constructing the new divs and the corresponding equalities, - * we have to replace each x'' by the corresponding row from C_2. + * we have to replace each x'', i.e., the x'_k with (g_kk = 1), + * by the corresponding row from C_2. */ static struct isl_basic_map *normalize_divs( struct isl_basic_map *bmap, int *progress) @@ -758,7 +759,7 @@ static struct isl_basic_map *normalize_divs( for (j = 0; j < i; ++j) { if (isl_int_is_zero(T->row[i][j])) continue; - if (C2) + if (pos[j] < T->n_row && C2) isl_seq_submul(bmap->div[k] + 1, T->row[i][j], C2->row[pos[j]], 1 + total); else diff --git a/isl_test.c b/isl_test.c index 8db04a4..9ec4a8a 100644 --- a/isl_test.c +++ b/isl_test.c @@ -266,6 +266,35 @@ void test_div(struct isl_ctx *ctx) assert(bset->n_div == 1); isl_basic_set_free(bset); + /* test 8 */ + dim = isl_dim_set_alloc(ctx, 0, 4); + bset = isl_basic_set_universe(dim); + + c = isl_equality_alloc(isl_dim_copy(bset->dim)); + isl_int_set_si(v, -1); + isl_constraint_set_coefficient(c, isl_dim_set, 0, v); + isl_int_set_si(v, -3); + isl_constraint_set_coefficient(c, isl_dim_set, 1, v); + isl_int_set_si(v, -3); + isl_constraint_set_coefficient(c, isl_dim_set, 3, v); + div = isl_div_alloc(isl_dim_copy(bset->dim)); + c = isl_constraint_add_div(c, div, &pos); + isl_int_set_si(v, 6); + isl_constraint_set_coefficient(c, isl_dim_div, pos, v); + bset = isl_basic_set_add_constraint(bset, c); + + c = isl_equality_alloc(isl_dim_copy(bset->dim)); + isl_int_set_si(v, -1); + isl_constraint_set_coefficient(c, isl_dim_set, 0, v); + isl_int_set_si(v, 1); + isl_constraint_set_coefficient(c, isl_dim_set, 2, v); + isl_int_set_si(v, 1); + isl_constraint_set_constant(c, v); + bset = isl_basic_set_add_constraint(bset, c); + + assert(bset->n_div == 1); + isl_basic_set_free(bset); + isl_int_clear(v); } -- 2.7.4