From 5e5bf20dd20abdbb96d6897f780fd72e4737bd59 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 19 Apr 2013 10:08:11 +0200 Subject: [PATCH] isl_ast_build_ast_from_schedule: also add stride guard in generic case Any guard implied by the stride constraint in the AST build domain needs to be enforced by the generated AST and may not necessarily be implied by the strided loop itself. We were already adding this guard to the graft in the degenerate case, but not in the generic case. The implied guard is usually already available in loop bounds constraints, so it is not clear if this fixes any bug that can appear in practice, However, this may just be a consequence of the internal representation of sets and we should not depend too much on this internal representation. Signed-off-by: Sven Verdoolaege --- isl_ast_codegen.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/isl_ast_codegen.c b/isl_ast_codegen.c index 3eb964bb..a0717a98 100644 --- a/isl_ast_codegen.c +++ b/isl_ast_codegen.c @@ -1155,6 +1155,28 @@ static __isl_give isl_ast_graft *refine_generic_split( return graft; } +/* Add the guard implied by the current stride constraint (if any), + * but not (necessarily) enforced by the generated AST to "graft". + */ +static __isl_give isl_ast_graft *add_stride_guard( + __isl_take isl_ast_graft *graft, __isl_keep isl_ast_build *build) +{ + int depth; + isl_set *dom; + + depth = isl_ast_build_get_depth(build); + if (!isl_ast_build_has_stride(build, depth)) + return graft; + + dom = isl_ast_build_get_stride_constraint(build); + dom = isl_set_eliminate(dom, isl_dim_set, depth, 1); + dom = isl_ast_build_compute_gist(build, dom); + + graft = isl_ast_graft_add_guard(graft, dom, build); + + return graft; +} + /* Update "graft" based on "bounds" and "domain" for the generic, * non-degenerate, case. * @@ -1181,6 +1203,7 @@ static __isl_give isl_ast_graft *refine_generic( list = isl_constraint_list_from_basic_set(bounds); graft = refine_generic_split(graft, list, domain, build); + graft = add_stride_guard(graft, build); isl_constraint_list_free(list); return graft; -- 2.11.4.GIT