From 899f82ceca6edbc939c5d37ff3209c85dca2c6a0 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 16 Dec 2012 19:38:32 +0100 Subject: [PATCH] isl_ast_codegen.c: compute_class_domains: compute gist of class domains The class domains may reference variables that been eliminated from the "executed" map. Constraints involving these variables may therefore get accidentally reintroduced into the "executed" map, which can render the AST build unable to detect whether the inner "executed" map is single-valued, possibly causing an infinite recursion. Plug in the values that caused the variables to be eliminated from the "executed" map to remove any reference to them from the class domains. Reported-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- isl_ast_codegen.c | 1 + test_inputs/codegen/separation_class3.c | 28 ++++++++++++++++++++++++++++ test_inputs/codegen/separation_class3.in | 4 ++++ 3 files changed, 33 insertions(+) create mode 100644 test_inputs/codegen/separation_class3.c create mode 100644 test_inputs/codegen/separation_class3.in diff --git a/isl_ast_codegen.c b/isl_ast_codegen.c index 9d4d93b9..b262fed9 100644 --- a/isl_ast_codegen.c +++ b/isl_ast_codegen.c @@ -2520,6 +2520,7 @@ static int compute_class_domains(__isl_take isl_point *pnt, void *user) 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); diff --git a/test_inputs/codegen/separation_class3.c b/test_inputs/codegen/separation_class3.c new file mode 100644 index 00000000..14f722ac --- /dev/null +++ b/test_inputs/codegen/separation_class3.c @@ -0,0 +1,28 @@ +for (int c0 = 0; c0 <= 4; c0 += 1) { + if (c0 >= 1) { + S_0(2 * c0 - 1, 1); + if (c0 == 4) + for (int c6 = 3; c6 <= 5; c6 += 1) + S_0(7, c6); + if (c0 <= 3) + for (int c4 = 2 * c0 - 1; c4 <= 2 * c0; c4 += 1) + for (int c6 = -2 * c0 + c4 + 4; c6 <= 2 * c0 - c4 + 4; c6 += 1) + S_0(c4, c6); + } else + S_0(0, 4); + for (int c4 = max(0, 2 * c0 - 1); c4 <= min(2 * c0, 7); c4 += 1) + for (int c6 = -2 * c0 + c4 + 8; c6 <= 8; c6 += 1) + S_0(c4, c6); + if (c0 >= 1 && c0 <= 3) { + for (int c2 = 0; c2 <= 1; c2 += 1) + for (int c4 = 2 * c0 - 1; c4 <= 2 * c0; c4 += 1) + for (int c6 = 2 * c0 + 4 * c2 - c4 + 1; c6 <= -2 * c0 + 4 * c2 + c4 + 3; c6 += 1) + S_0(c4, c6); + } else if (c0 == 4) { + for (int c2 = 0; c2 <= 1; c2 += 1) + S_0(7, 4 * c2 + 2); + } else + for (int c2 = 0; c2 <= 1; c2 += 1) + for (int c6 = 4 * c2 + 1; c6 <= 4 * c2 + 3; c6 += 1) + S_0(0, c6); +} diff --git a/test_inputs/codegen/separation_class3.in b/test_inputs/codegen/separation_class3.in new file mode 100644 index 00000000..1aaf2517 --- /dev/null +++ b/test_inputs/codegen/separation_class3.in @@ -0,0 +1,4 @@ +{ S_0[t, i] -> [o0, 1, o2, 0, t, 0, i] : 4o2 >= -4 + t + i - 2o0 and 4o2 >= -3 - t + i + 2o0 and 2o0 <= 1 + t and 2o0 >= t and 4o2 <= -1 + t + i - 2o0 and t >= 0 and t <= 7 and i >= 1 and i <= 8; S_0[t, i] -> [o0, 0, o2, 0, t, 0, i] : 4o2 >= t + i - 2o0 and 4o2 <= -t + i + 2o0 and 2o0 <= 1 + t and 2o0 >= t and t >= 0 and t <= 7 and i >= 1 and i <= 8 } +{:} +{ [i0, 1, i2, i3, i4, i5, i6] -> separation_class[[2] -> [0]] : i2 <= 1 and i2 >= 0 and i0 <= 3 and i0 >= 1; [i0, 0, 1, i3, i4, i5, i6] -> separation_class[[2] -> [0]] : i0 <= 3 and i0 >= 1; [i0, i1, i2, i3, i4, i5, i6] -> unroll[1] } + -- 2.11.4.GIT