isl_union_set_compute_schedule: handle result with zero bands
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 10 Oct 2012 10:36:37 +0000 (12:36 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 10 Oct 2012 10:47:56 +0000 (12:47 +0200)
The code in extract_schedule would assume that there is at least
one band in the resulting schedule.  Skip the parts that depend
on this assumption when the number of bands is zero.

Reported-by: Sameer Sahasrabuddhe <Sameer.Sahasrabuddhe@amd.com>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c
isl_test.c

index dc9e19f..f2c3c89 100644 (file)
@@ -1732,11 +1732,18 @@ static __isl_give isl_schedule *extract_schedule(struct isl_sched_graph *graph,
                int r, b;
                int *band_end, *band_id, *zero;
 
+               sched->node[i].sched =
+                       node_extract_schedule_multi_aff(&graph->node[i]);
+               if (!sched->node[i].sched)
+                       goto error;
+
+               sched->node[i].n_band = graph->n_band;
+               if (graph->n_band == 0)
+                       continue;
+
                band_end = isl_alloc_array(ctx, int, graph->n_band);
                band_id = isl_alloc_array(ctx, int, graph->n_band);
                zero = isl_alloc_array(ctx, int, graph->n_total_row);
-               sched->node[i].sched =
-                       node_extract_schedule_multi_aff(&graph->node[i]);
                sched->node[i].band_end = band_end;
                sched->node[i].band_id = band_id;
                sched->node[i].zero = zero;
index 6f4149f..fa018e3 100644 (file)
@@ -2314,6 +2314,10 @@ int test_schedule(isl_ctx *ctx)
 {
        const char *D, *W, *R, *V, *P, *S;
 
+       /* Handle resulting schedule with zero bands. */
+       if (test_one_schedule(ctx, "{[]}", "{}", "{}", "{[] -> []}", 0, 0) < 0)
+               return -1;
+
        /* Jacobi */
        D = "[T,N] -> { S1[t,i] : 1 <= t <= T and 2 <= i <= N - 1 }";
        W = "{ S1[t,i] -> a[t,i] }";