isl_ast_codegen.c: compute_class_domains: compute gist of class domains
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 16 Dec 2012 18:38:32 +0000 (19:38 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 16 Dec 2012 18:38:32 +0000 (19:38 +0100)
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 <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_codegen.c
test_inputs/codegen/separation_class3.c [new file with mode: 0644]
test_inputs/codegen/separation_class3.in [new file with mode: 0644]

index 9d4d93b..b262fed 100644 (file)
@@ -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 (file)
index 0000000..14f722a
--- /dev/null
@@ -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 (file)
index 0000000..1aaf251
--- /dev/null
@@ -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] }
+