isl_pw_qpolynomial_fold_bound: avoid access to freed memory
[platform/upstream/isl.git] / isl_test.c
index e64ef43..ab446a2 100644 (file)
@@ -1480,6 +1480,28 @@ void test_pwqp(struct isl_ctx *ctx)
        assert(isl_pw_qpolynomial_is_zero(pwqp1));
 
        isl_pw_qpolynomial_free(pwqp1);
+
+       str = "{ [i] -> ([([i/2] + [i/2])/5]) }";
+       pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str);
+       str = "{ [i] -> ([(2 * [i/2])/5]) }";
+       pwqp2 = isl_pw_qpolynomial_read_from_str(ctx, str);
+
+       pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
+
+       assert(isl_pw_qpolynomial_is_zero(pwqp1));
+
+       isl_pw_qpolynomial_free(pwqp1);
+
+       str = "{ [x] -> ([x/2] + [(x+1)/2]) }";
+       pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str);
+       str = "{ [x] -> x }";
+       pwqp2 = isl_pw_qpolynomial_read_from_str(ctx, str);
+
+       pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
+
+       assert(isl_pw_qpolynomial_is_zero(pwqp1));
+
+       isl_pw_qpolynomial_free(pwqp1);
 }
 
 void test_split_periods(isl_ctx *ctx)
@@ -1541,6 +1563,20 @@ void test_bound(isl_ctx *ctx)
        isl_pw_qpolynomial_fold_free(pwf);
 }
 
+void test_lift(isl_ctx *ctx)
+{
+       const char *str;
+       isl_basic_map *bmap;
+       isl_basic_set *bset;
+
+       str = "{ [i0] : exists e0 : i0 = 4e0 }";
+       bset = isl_basic_set_read_from_str(ctx, str, 0);
+       bset = isl_basic_set_lift(bset);
+       bmap = isl_basic_map_from_range(bset);
+       bset = isl_basic_map_domain(bmap);
+       isl_basic_set_free(bset);
+}
+
 int main()
 {
        struct isl_ctx *ctx;
@@ -1549,6 +1585,7 @@ int main()
        assert(srcdir);
 
        ctx = isl_ctx_alloc();
+       test_lift(ctx);
        test_bound(ctx);
        test_union(ctx);
        test_split_periods(ctx);