From b4ae615a414b4961b32f75c7510bbcb961e0d8fe Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 24 Apr 2014 11:03:22 +0200 Subject: [PATCH] isl_flow.c: compute_val_based_dependences: use correct space for partial results In 0eacaaa (isl_access_info_compute_flow: handle may accesses, Wed May 26 20:51:25 2010 +0200), the "dep" array of isl_flow was extended to keep track of both may and must dependences (for must sources). However, the initialization of must_rel inside compute_val_based_dependences was not modified to take into account that this array contains two dependence relations per must source, possibly resulting in the use of the wrong space. This problem went mostly unnoticed because must_rel is later updated by isl_map_union_disjoint and isl_map_union_disjoint does not currently check if the inputs live in the same space when the first input is empty. Instead, it simply returns the second input. However, there are some cases where the space of must_rel, while it still has its original empty value living in the wrong space. Signed-off-by: Sven Verdoolaege --- isl_flow.c | 2 +- isl_test.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/isl_flow.c b/isl_flow.c index a263d95f..c4beff29 100644 --- a/isl_flow.c +++ b/isl_flow.c @@ -943,7 +943,7 @@ static __isl_give isl_flow *compute_val_based_dependences( for (level = depth; level >= 1; --level) { for (j = acc->n_must-1; j >=0; --j) { - must_rel[j] = isl_map_empty_like(res->dep[j].map); + must_rel[j] = isl_map_empty_like(res->dep[2 * j].map); may_rel[j] = isl_map_copy(must_rel[j]); } diff --git a/isl_test.c b/isl_test.c index d1928100..f96d5466 100644 --- a/isl_test.c +++ b/isl_test.c @@ -2023,6 +2023,33 @@ void test_dep(struct isl_ctx *ctx) isl_flow_free(flow); } +/* Check that the dependence analysis proceeds without errors. + * Earlier versions of isl would break down during the analysis + * due to the use of the wrong spaces. + */ +static int test_flow(isl_ctx *ctx) +{ + const char *str; + isl_union_map *access, *schedule; + isl_union_map *must_dep, *may_dep; + int r; + + str = "{ S0[j] -> i[]; S1[j,i] -> i[]; S2[] -> i[]; S3[] -> i[] }"; + access = isl_union_map_read_from_str(ctx, str); + str = "{ S0[j] -> [0,j,0,0] : 0 <= j < 10; " + "S1[j,i] -> [0,j,1,i] : 0 <= j < i < 10; " + "S2[] -> [1,0,0,0]; " + "S3[] -> [-1,0,0,0] }"; + schedule = isl_union_map_read_from_str(ctx, str); + r = isl_union_map_compute_flow(access, isl_union_map_copy(access), + isl_union_map_copy(access), schedule, + &must_dep, &may_dep, NULL, NULL); + isl_union_map_free(may_dep); + isl_union_map_free(must_dep); + + return r; +} + int test_sv(isl_ctx *ctx) { const char *str; @@ -4840,6 +4867,7 @@ struct { const char *name; int (*fn)(isl_ctx *ctx); } tests [] = { + { "dependence analysis", &test_flow }, { "val", &test_val }, { "compute divs", &test_compute_divs }, { "partial lexmin", &test_partial_lexmin }, -- 2.11.4.GIT