isl_union_set_compute_schedule: ignore backward proximity edges on split
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 14 Apr 2012 21:21:55 +0000 (23:21 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 18 Apr 2012 07:55:20 +0000 (09:55 +0200)
Proximity edges are not taken into account during the detection
of strongly connected components.  When we split the dependence graph
based on these SCCs, we may therefore have proximity edges that go
back from a SCC behind the split to a SCC ahead of the split.  These should
be ignored, just like those edges that go from ahead of the split to behind
the split.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c

index 65573f5..7435a55 100644 (file)
@@ -1642,6 +1642,9 @@ static int copy_nodes(struct isl_sched_graph *dst, struct isl_sched_graph *src,
 
 /* Copy non-empty edges that satisfy edge_pred from the src dependence graph
  * to the dst dependence graph.
+ * If the source or destination node of the edge is not in the destination
+ * graph, then it must be a backward proximity edge and it should simply
+ * be ignored.
  */
 static int copy_edges(isl_ctx *ctx, struct isl_sched_graph *dst,
        struct isl_sched_graph *src,
@@ -1653,6 +1656,7 @@ static int copy_edges(isl_ctx *ctx, struct isl_sched_graph *dst,
        for (i = 0; i < src->n_edge; ++i) {
                struct isl_sched_edge *edge = &src->edge[i];
                isl_map *map;
+               struct isl_sched_node *dst_src, *dst_dst;
 
                if (!edge_pred(edge, data))
                        continue;
@@ -1660,12 +1664,19 @@ static int copy_edges(isl_ctx *ctx, struct isl_sched_graph *dst,
                if (isl_map_plain_is_empty(edge->map))
                        continue;
 
+               dst_src = graph_find_node(ctx, dst, edge->src->dim);
+               dst_dst = graph_find_node(ctx, dst, edge->dst->dim);
+               if (!dst_src || !dst_dst) {
+                       if (edge->validity)
+                               isl_die(ctx, isl_error_internal,
+                                       "backward validity edge", return -1);
+                       continue;
+               }
+
                map = isl_map_copy(edge->map);
 
-               dst->edge[dst->n_edge].src =
-                       graph_find_node(ctx, dst, edge->src->dim);
-               dst->edge[dst->n_edge].dst =
-                       graph_find_node(ctx, dst, edge->dst->dim);
+               dst->edge[dst->n_edge].src = dst_src;
+               dst->edge[dst->n_edge].dst = dst_dst;
                dst->edge[dst->n_edge].map = map;
                dst->edge[dst->n_edge].validity = edge->validity;
                dst->edge[dst->n_edge].proximity = edge->proximity;