From 785866aee5b6ec168cbbeb215be1166a31e6de45 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 24 Oct 2017 14:47:35 +0200 Subject: [PATCH] isl_*_aff_read_from_str: do not read domains as rational sets When support for parsing rational sets was added in isl-0.10-176-gce84f3f800 (isl_stream_read_map: add partial support for reading rational sets, Sun Jul 15 09:52:53 2012 +0200), the reading of domains of affine expressions was changed to read those domains as rational sets (without motivation). While the expressions themselves may be rational, there is no need to assume that the domain is rational. Furthermore, when printing affine functions, a rational domain is not marked in any way, resulting in an affine function that looks identical to one with an integral domain but that is different, as, for example, in the new test case. Read the domains as integral sets to avoid this confusion. Signed-off-by: Sven Verdoolaege --- isl_input.c | 4 ++-- isl_test.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/isl_input.c b/isl_input.c index e122053e..d460b068 100644 --- a/isl_input.c +++ b/isl_input.c @@ -3122,7 +3122,7 @@ static __isl_give isl_set *read_aff_domain(__isl_keep isl_stream *s, tok = isl_stream_next_token(s); if (tok && (tok->type == ISL_TOKEN_IDENT || tok->is_keyword)) { isl_stream_push_token(s, tok); - return read_map_tuple(s, dom, isl_dim_set, v, 1, 0); + return read_map_tuple(s, dom, isl_dim_set, v, 0, 0); } if (!tok || tok->type != '[') { isl_stream_error(s, tok, "expecting '['"); @@ -3134,7 +3134,7 @@ static __isl_give isl_set *read_aff_domain(__isl_keep isl_stream *s, isl_stream_push_token(s, tok2); if (is_empty || next_is_tuple(s) || next_is_fresh_ident(s, v)) { isl_stream_push_token(s, tok); - dom = read_map_tuple(s, dom, isl_dim_set, v, 1, 0); + dom = read_map_tuple(s, dom, isl_dim_set, v, 0, 0); } else isl_stream_push_token(s, tok); diff --git a/isl_test.c b/isl_test.c index d38c4fc1..a8cd5c8c 100644 --- a/isl_test.c +++ b/isl_test.c @@ -4766,6 +4766,56 @@ static int test_bin_upma_fail(isl_ctx *ctx) return 0; } +/* Inputs for basic tests of binary operations on + * pairs of isl_multi_union_pw_aff and isl_union_set objects. + * "fn" is the function that is tested. + * "arg1" and "arg2" are string descriptions of the inputs. + * "res" is a string description of the expected result. + */ +struct { + __isl_give isl_multi_union_pw_aff *(*fn)( + __isl_take isl_multi_union_pw_aff *mupa, + __isl_take isl_union_set *uset); + const char *arg1; + const char *arg2; + const char *res; +} mupa_uset_tests[] = { + { &isl_multi_union_pw_aff_intersect_domain, + "C[{ B[i,j] -> [i + 2j] }]", "{ B[i,i] }", + "C[{ B[i,i] -> [3i] }]" }, +}; + +/* Perform some basic tests of binary operations on + * pairs of isl_multi_union_pw_aff and isl_union_set objects. + */ +static int test_mupa_uset(isl_ctx *ctx) +{ + int i; + isl_bool ok; + isl_multi_union_pw_aff *mupa, *res; + isl_union_set *uset; + + for (i = 0; i < ARRAY_SIZE(mupa_uset_tests); ++i) { + mupa = isl_multi_union_pw_aff_read_from_str(ctx, + mupa_uset_tests[i].arg1); + uset = isl_union_set_read_from_str(ctx, + mupa_uset_tests[i].arg2); + res = isl_multi_union_pw_aff_read_from_str(ctx, + mupa_uset_tests[i].res); + mupa = mupa_uset_tests[i].fn(mupa, uset); + ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res); + isl_multi_union_pw_aff_free(mupa); + isl_multi_union_pw_aff_free(res); + if (ok < 0) + return -1; + if (!ok) + isl_die(ctx, isl_error_unknown, + "unexpected result", return -1); + } + + return 0; +} + int test_aff(isl_ctx *ctx) { const char *str; @@ -4783,6 +4833,8 @@ int test_aff(isl_ctx *ctx) return -1; if (test_bin_upma_fail(ctx) < 0) return -1; + if (test_mupa_uset(ctx) < 0) + return -1; space = isl_space_set_alloc(ctx, 0, 1); ls = isl_local_space_from_space(space); -- 2.11.4.GIT