isl_map_simplify.c: normalize_divs: ensure enough existentials are available
[platform/upstream/isl.git] / isl_test.c
index c2516c8..8db04a4 100644 (file)
@@ -237,6 +237,35 @@ void test_div(struct isl_ctx *ctx)
        assert(bset->n_div == 1);
        isl_basic_set_free(bset);
 
+       /* test 7 */
+       /* This test is a bit tricky.  We set up an equality
+        *              a + 3b + 3c = 6 e0
+        * Normalization of divs creates _two_ divs
+        *              a = 3 e0
+        *              c - b - e0 = 2 e1
+        * Afterwards e0 is removed again because it has coefficient -1
+        * and we end up with the original equality and div again.
+        * Perhaps we can avoid the introduction of this temporary div.
+        */
+       dim = isl_dim_set_alloc(ctx, 0, 3);
+       bset = isl_basic_set_universe(dim);
+
+       c = isl_equality_alloc(isl_dim_copy(bset->dim));
+       isl_int_set_si(v, -1);
+       isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+       isl_int_set_si(v, -3);
+       isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+       isl_int_set_si(v, -3);
+       isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+       div = isl_div_alloc(isl_dim_copy(bset->dim));
+       c = isl_constraint_add_div(c, div, &pos);
+       isl_int_set_si(v, 6);
+       isl_constraint_set_coefficient(c, isl_dim_div, pos, v);
+       bset = isl_basic_set_add_constraint(bset, c);
+
+       assert(bset->n_div == 1);
+       isl_basic_set_free(bset);
+
        isl_int_clear(v);
 }