From 00a81d91c7e2472c4461350a371ea0e72af1e32b Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 17 Mar 2011 17:47:52 +0100 Subject: [PATCH] isl_stream_read_map: properly read nested divs Signed-off-by: Sven Verdoolaege --- isl_input.c | 1 + isl_test.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/isl_input.c b/isl_input.c index 7ac72281..607732ef 100644 --- a/isl_input.c +++ b/isl_input.c @@ -323,6 +323,7 @@ static __isl_give isl_vec *accept_affine_factor(struct isl_stream *s, tok = NULL; if (read_div_definition(s, v) < 0) goto error; + aff = isl_vec_zero_extend(aff, 1 + v->n); } else { isl_stream_error(s, tok, "expecting factor"); goto error; diff --git a/isl_test.c b/isl_test.c index 2d398f47..46177d61 100644 --- a/isl_test.c +++ b/isl_test.c @@ -30,6 +30,17 @@ void test_parse_map(isl_ctx *ctx, const char *str) isl_map_free(map); } +void test_parse_map_equal(isl_ctx *ctx, const char *str, const char *str2) +{ + isl_map *map, *map2; + + map = isl_map_read_from_str(ctx, str, -1); + map2 = isl_map_read_from_str(ctx, str2, -1); + assert(map && map2 && isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); +} + void test_parse_pwqp(isl_ctx *ctx, const char *str) { isl_pw_qpolynomial *pwqp; @@ -42,7 +53,7 @@ void test_parse_pwqp(isl_ctx *ctx, const char *str) void test_parse(struct isl_ctx *ctx) { isl_map *map, *map2; - const char *str; + const char *str, *str2; str = "{ [i] -> [-i] }"; map = isl_map_read_from_str(ctx, str, -1); @@ -58,6 +69,10 @@ void test_parse(struct isl_ctx *ctx) test_parse_map(ctx, "{ [p1, y1, y2] -> [2, y1, y2] : " "p1 = 1 && (y1 <= y2 || y2 = 0) }"); + str = "{ [x,y] : [([x/2]+y)/3] >= 1 }"; + str2 = "{ [x, y] : 2y >= 6 - x }"; + test_parse_map_equal(ctx, str, str2); + str = "{[new,old] -> [new+1-2*[(new+1)/2],old+1-2*[(old+1)/2]]}"; map = isl_map_read_from_str(ctx, str, -1); str = "{ [new, old] -> [o0, o1] : " -- 2.11.4.GIT