From: Sven Verdoolaege Date: Tue, 22 Nov 2011 12:54:00 +0000 (+0100) Subject: isl_union_pw_*_{intersect_domain,gist}: update to change of isl_pw_* space X-Git-Tag: isl-0.09~14^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5d70b079199801b6ec47a4b9ab867695a92d9db;p=platform%2Fupstream%2Fisl.git isl_union_pw_*_{intersect_domain,gist}: update to change of isl_pw_* space In 3280c05 (make isl_pw_* object live in a map space, Tue Aug 30 16:47:59 2011 +0200), the space in which objects live was changed from that of its domain to that of a map, but isl_union_pw_*_{intersect_domain,gist} were not changed accordingly. Signed-off-by: Sven Verdoolaege --- diff --git a/isl_test.c b/isl_test.c index eb8b151..eb061dc 100644 --- a/isl_test.c +++ b/isl_test.c @@ -2493,6 +2493,30 @@ int test_fixed(isl_ctx *ctx) return 0; } +int test_union_pw(isl_ctx *ctx) +{ + int equal; + const char *str; + isl_union_set *uset; + isl_union_pw_qpolynomial *upwqp1, *upwqp2; + + str = "{ [x] -> x^2 }"; + upwqp1 = isl_union_pw_qpolynomial_read_from_str(ctx, str); + upwqp2 = isl_union_pw_qpolynomial_copy(upwqp1); + uset = isl_union_pw_qpolynomial_domain(upwqp1); + upwqp1 = isl_union_pw_qpolynomial_copy(upwqp2); + upwqp1 = isl_union_pw_qpolynomial_intersect_domain(upwqp1, uset); + equal = isl_union_pw_qpolynomial_plain_is_equal(upwqp1, upwqp2); + isl_union_pw_qpolynomial_free(upwqp1); + isl_union_pw_qpolynomial_free(upwqp2); + if (equal < 0) + return -1; + if (!equal) + isl_die(ctx, isl_error_unknown, "unexpected result", return -1); + + return 0; +} + int main() { struct isl_ctx *ctx; @@ -2515,6 +2539,8 @@ int main() goto error; if (test_schedule(ctx) < 0) goto error; + if (test_union_pw(ctx) < 0) + goto error; test_factorize(ctx); test_subset(ctx); test_lift(ctx); diff --git a/isl_union_templ.c b/isl_union_templ.c index eb33acc..30e7f3b 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -415,7 +415,7 @@ error: return NULL; } -S(UNION,match_set_data) { +S(UNION,match_domain_data) { isl_union_set *uset; UNION *res; __isl_give PW *(*fn)(__isl_take PW*, __isl_take isl_set*); @@ -429,17 +429,24 @@ static int set_has_dim(const void *entry, const void *val) return isl_space_is_equal(set->dim, dim); } -static int match_set_entry(void **entry, void *user) +/* Find the set in data->uset that live in the same space as the domain + * of *entry, apply data->fn to *entry and this set (if any), and add + * the result to data->res. + */ +static int match_domain_entry(void **entry, void *user) { - S(UNION,match_set_data) *data = user; + S(UNION,match_domain_data) *data = user; uint32_t hash; struct isl_hash_table_entry *entry2; PW *pw = *entry; + isl_space *space; int empty; - hash = isl_space_get_hash(pw->dim); + space = FN(PW,get_domain_space)(pw); + hash = isl_space_get_hash(space); entry2 = isl_hash_table_find(data->uset->dim->ctx, &data->uset->table, - hash, &set_has_dim, pw->dim, 0); + hash, &set_has_dim, space, 0); + isl_space_free(space); if (!entry2) return 0; @@ -461,11 +468,15 @@ static int match_set_entry(void **entry, void *user) return 0; } -static __isl_give UNION *match_set_op(__isl_take UNION *u, +/* Apply fn to each pair of PW in u and set in uset such that + * the set lives in the same space as the domain of PW + * and collect the results. + */ +static __isl_give UNION *match_domain_op(__isl_take UNION *u, __isl_take isl_union_set *uset, __isl_give PW *(*fn)(__isl_take PW*, __isl_take isl_set*)) { - S(UNION,match_set_data) data = { NULL, NULL, fn }; + S(UNION,match_domain_data) data = { NULL, NULL, fn }; u = FN(UNION,align_params)(u, isl_union_set_get_space(uset)); uset = isl_union_set_align_params(uset, FN(UNION,get_space)(u)); @@ -480,7 +491,7 @@ static __isl_give UNION *match_set_op(__isl_take UNION *u, data.res = FN(UNION,alloc)(isl_space_copy(u->dim), u->table.n); #endif if (isl_hash_table_foreach(u->dim->ctx, &u->table, - &match_set_entry, &data) < 0) + &match_domain_entry, &data) < 0) goto error; FN(UNION,free)(u); @@ -496,13 +507,13 @@ error: __isl_give UNION *FN(UNION,intersect_domain)(__isl_take UNION *u, __isl_take isl_union_set *uset) { - return match_set_op(u, uset, &FN(PW,intersect_domain)); + return match_domain_op(u, uset, &FN(PW,intersect_domain)); } __isl_give UNION *FN(UNION,gist)(__isl_take UNION *u, __isl_take isl_union_set *uset) { - return match_set_op(u, uset, &FN(PW,gist)); + return match_domain_op(u, uset, &FN(PW,gist)); } __isl_give isl_qpolynomial *FN(UNION,eval)(__isl_take UNION *u,