AST generator: detect partial executed relations that become empty
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 1 May 2014 10:43:38 +0000 (1 12:43 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 1 May 2014 10:43:38 +0000 (1 12:43 +0200)
In particular, detect those cases where they become empty
when intersected with the context at the innermost level.
At outer levels a similar test is already performed after
the call to isl_ast_build_compute_gist from add_node.

It may be better to detect these situations at an earlier stage,
but for now we just fix the immediate problem.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_codegen.c
test_inputs/codegen/empty.c [new file with mode: 0644]
test_inputs/codegen/empty.in [new file with mode: 0644]

index 3626b68..8221348 100644 (file)
@@ -145,7 +145,7 @@ static __isl_give isl_ast_graft *at_each_domain(__isl_take isl_ast_graft *graft,
 }
 
 /* Generate an AST for a single domain based on
- * the inverse schedule "executed".
+ * the inverse schedule "executed" and add it to data->list.
  *
  * If there is more than one domain element associated to the current
  * schedule "time", then we need to continue the generation process
@@ -180,11 +180,18 @@ static int generate_domain(__isl_take isl_map *executed, void *user)
        isl_ast_graft *graft;
        isl_ast_graft_list *list;
        isl_set *guard;
-       isl_map *map;
-       int sv;
+       isl_map *map = NULL;
+       int empty, sv;
 
        executed = isl_map_intersect_domain(executed,
                                            isl_set_copy(data->build->domain));
+       empty = isl_map_is_empty(executed);
+       if (empty < 0)
+               goto error;
+       if (empty) {
+               isl_map_free(executed);
+               return 0;
+       }
 
        executed = isl_map_coalesce(executed);
        map = isl_map_copy(executed);
diff --git a/test_inputs/codegen/empty.c b/test_inputs/codegen/empty.c
new file mode 100644 (file)
index 0000000..0205735
--- /dev/null
@@ -0,0 +1,6 @@
+for (int c0 = 0; c0 <= 10; c0 += 1) {
+  S0(c0);
+  S1(c0);
+  if (c0 == 5)
+    S2();
+}
diff --git a/test_inputs/codegen/empty.in b/test_inputs/codegen/empty.in
new file mode 100644 (file)
index 0000000..17febea
--- /dev/null
@@ -0,0 +1,5 @@
+# Earlier versions of isl would end up with an empty partial
+# executed relation and fail to detect this emptiness.
+[M] -> { S0[i] -> [i, -M] : 0 <= i <= 10; S1[i] -> [i, 0] : 0 <= i <= 10; S2[] -> [5, 0] }
+[M] -> {  : M >= 1 }
+{ }