identity = isl_set_identity(isl_map_range(isl_map_copy(executed)));
executed = isl_map_domain_product(executed, identity);
+ build = isl_ast_build_set_single_valued(build, 1);
list = generate_code(isl_union_map_from_map(executed), build, 1);
* the constraints from data->build->domain.
* On the other hand, we only perform the test after having taken the gist
* of the domain as the resulting map is the one from which the call
- * expression is constructed.
+ * expression is constructed. Using this map to construct the call
+ * expression usually yields simpler results.
+ * Because we perform the single-valuedness test on the gisted map,
+ * we may in rare cases fail to recognize that the inverse schedule
+ * is single-valued. This becomes problematic if this happens
+ * from the recursive call through generate_non_single_valued
+ * as we would then end up in an infinite recursion.
+ * We therefore check if we are inside a call to generate_non_single_valued
+ * and revert to the ungisted map if the gisted map turns out not to be
+ * single-valued.
*
* Otherwise, we generate a call expression for the single executed
* domain element and put a guard around it based on the (simplified)
goto error;
if (!sv) {
isl_map_free(map);
- return generate_non_single_valued(executed, data);
+ if (data->build->single_valued)
+ map = isl_map_copy(executed);
+ else
+ return generate_non_single_valued(executed, data);
}
guard = isl_map_domain(isl_map_copy(map));
guard = isl_set_coalesce(guard);
if (isl_aff_get_denominator(offset, &data.d) < 0)
executed = isl_union_map_free(executed);
- if (isl_int_is_divisible_by(data.m, data.d))
+ if (executed && isl_int_is_divisible_by(data.m, data.d))
isl_int_divexact(data.m, data.m, data.d);
else
isl_int_set_si(data.m, 1);
data.depth = isl_ast_build_get_depth(build);
data.piece = domain_list->p;
g = isl_tarjan_graph_init(ctx, n, &domain_follows_at_depth, &data);
+ if (!g)
+ goto error;
i = 0;
while (list && n) {
class_set = isl_set_from_point(pnt);
domain = isl_map_domain(isl_map_intersect_range(
isl_map_copy(domains->sep_class), class_set));
+ domain = isl_ast_build_compute_gist(domains->build, domain);
domain = isl_ast_build_eliminate(domains->build, domain);
disjoint = isl_set_plain_is_disjoint(domain, domains->schedule_domain);
enum isl_ast_build_domain_type type;
int empty;
+ if (!executed)
+ return NULL;
+
ctx = isl_union_map_get_ctx(executed);
domains.list = isl_basic_set_list_alloc(ctx, 0);
isl_ast_node *node;
isl_union_map *executed;
+ build = isl_ast_build_copy(build);
+ build = isl_ast_build_set_single_valued(build, 0);
executed = isl_union_map_reverse(schedule);
list = generate_code(executed, isl_ast_build_copy(build), 0);
node = isl_ast_node_from_graft_list(list, build);
+ isl_ast_build_free(build);
return node;
}