- struct isl_set *set, *set2;
- struct isl_map *map, *map2;
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or "
- "y >= x & x >= 2 & 5 >= y }");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
- "x + y >= 10 & y <= x & x + y <= 20 & y >= 0}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
- "x + y >= 10 & y <= x & x + y <= 19 & y >= 0}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 2);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x >= 6 & x <= 10 & y <= x}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x >= 7 & x <= 10 & y <= x}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 2);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 2);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x = 6 & y <= 6}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x = 7 & y <= 6}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 2);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x = 6 & y <= 5}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- set2 = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x = 6 & y <= 5}");
- assert(isl_set_is_equal(set, set2));
- isl_set_free(set);
- isl_set_free(set2);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y]: y >= 0 & x <= 5 & y <= x or "
- "y >= 0 & x = 6 & y <= 7}");
- set = isl_set_coalesce(set);
- assert(set && set->n == 2);
- isl_set_free(set);
-
- set = isl_set_read_from_str(ctx,
- "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- set2 = isl_set_read_from_str(ctx,
- "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }");
- assert(isl_set_is_equal(set, set2));
- isl_set_free(set);
- isl_set_free(set2);
-
- set = isl_set_read_from_str(ctx,
- "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}");
- set = isl_set_coalesce(set);
- set2 = isl_set_read_from_str(ctx,
- "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}");
- assert(isl_set_is_equal(set, set2));
- isl_set_free(set);
- isl_set_free(set2);
-
- set = isl_set_read_from_str(ctx,
- "[n] -> { [i] : 1 <= i and i <= n - 1 or "
- "2 <= i and i <= n }");
- set = isl_set_coalesce(set);
- assert(set && set->n == 1);
- set2 = isl_set_read_from_str(ctx,
- "[n] -> { [i] : 1 <= i and i <= n - 1 or "
- "2 <= i and i <= n }");
- assert(isl_set_is_equal(set, set2));
- isl_set_free(set);
- isl_set_free(set2);
-
- map = isl_map_read_from_str(ctx,
- "[n] -> { [i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
- "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
- "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
- "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and "
- "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and "
- "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and "
- "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and "
- "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);"
- "[i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
- "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
- "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
- "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and "
- "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and "
- "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and "
- "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and "
- "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and "
- "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and "
- "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }");
- map = isl_map_coalesce(map);
- map2 = isl_map_read_from_str(ctx,
- "[n] -> { [i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
+} coalesce_tests[] = {
+ { 1, "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or "
+ "y >= x & x >= 2 & 5 >= y }" },
+ { 1, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
+ "x + y >= 10 & y <= x & x + y <= 20 & y >= 0}" },
+ { 0, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
+ "x + y >= 10 & y <= x & x + y <= 19 & y >= 0}" },
+ { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
+ "y >= 0 & x >= 6 & x <= 10 & y <= x}" },
+ { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
+ "y >= 0 & x >= 7 & x <= 10 & y <= x}" },
+ { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
+ "y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}" },
+ { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 6}" },
+ { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 7 & y <= 6}" },
+ { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 5}" },
+ { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 7}" },
+ { 1, "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }" },
+ { 0, "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}" },
+ { 1, "[n] -> { [i] : 1 <= i and i <= n - 1 or 2 <= i and i <= n }" },
+ { 0, "[n] -> { [[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "