isl_stream_read_map: properly read nested divs
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 17 Mar 2011 16:47:52 +0000 (17:47 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 18 Mar 2011 11:21:03 +0000 (12:21 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_input.c
isl_test.c

index 7ac7228..607732e 100644 (file)
@@ -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;
index 2d398f4..46177d6 100644 (file)
@@ -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] : "