isl_stream_read_map: fix handling of divs in tuples
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 11 Apr 2011 18:56:48 +0000 (20:56 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 11 Apr 2011 19:20:06 +0000 (21:20 +0200)
Supoprt for them was broken in f1ea969 (isl_stream_read_map: treat divs
as output variables while adding constraints, Thu Mar 17 16:29:06 2011 +0100).
When treating divs as output variables, we need to make sure that
each of them is backed by a variable in the list of active variables.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_input.c
isl_test.c

index d979f1e..fd46257 100644 (file)
@@ -1254,11 +1254,16 @@ static isl_map *read_constraint(struct isl_stream *s,
 {
        int n = v->n;
        isl_map *map;
+       unsigned total;
 
        if (!bmap)
                return NULL;
 
        bmap = isl_basic_set_unwrap(isl_basic_set_lift(isl_basic_map_wrap(bmap)));
+       total = isl_basic_map_total_dim(bmap);
+       while (v->n < total)
+               if (vars_add_anon(v) < 0)
+                       goto error;
 
        bmap = add_constraint(s, v, bmap);
        bmap = isl_basic_map_simplify(bmap);
@@ -1273,6 +1278,9 @@ static isl_map *read_constraint(struct isl_stream *s,
        vars_drop(v, v->n - n);
 
        return map;
+error:
+       isl_basic_map_free(bmap);
+       return NULL;
 }
 
 static struct isl_map *read_disjuncts(struct isl_stream *s,
index 1f2c6f1..01839c3 100644 (file)
@@ -102,6 +102,7 @@ void test_parse(struct isl_ctx *ctx)
        test_parse_map_equal(ctx, str, str2);
 
        test_parse_pwqp(ctx, "{ [i] -> i + [ (i + [i/3])/2 ] }");
+       test_parse_map(ctx, "{ S1[i] -> [([i/10]),i%10] : 0 <= i <= 45 }");
 }
 
 void test_read(struct isl_ctx *ctx)