From 47bfbac688609f5e1ee0f65eaf082573b4473992 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 28 Mar 2014 11:36:01 +0100 Subject: [PATCH] gpu.c: add_bounded_parameters_dynamic: compute simple hull of bounds The function add_bounded_parameters_dynamic is used to compute bounds on the block identifiers that can be used to simplify the AST generated by the AST generator. The set of possible values (or an overapproximation thereof) is derived from block size. The block size is typically an (implicit) max expression. Since isl may not realize that the size is in fact a max expression, the set of possible values may end up being described by more than one disjunct. This in turn may confuse the AST generator, resulting in redundant conditions in the generated AST. We may be able to improve the AST generator to not get confused by these disjuncts, but we might as well replace the set of possible values by its simple hull. When the size is indeed a max expression, this simple hull is equal to the original set, but described using a single disjunct. Otherwise, the result may be an overapproximation but since the set is only used to simplify expressions, this overapproximation should not have any adverse effects. Signed-off-by: Sven Verdoolaege --- gpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gpu.c b/gpu.c index d52eabd..4611534 100644 --- a/gpu.c +++ b/gpu.c @@ -1365,8 +1365,12 @@ __isl_give isl_set *add_bounded_parameters(__isl_take isl_set *set, return isl_set_intersect(set, isl_set_from_basic_set(bset)); } -/* Add "len" parameters p[i] called prefix%d, - * with bounds to 0 <= p[i] < size[i]. +/* Add "len" parameters p[i] called prefix%d and intersect "set" + * with + * + * { : 0 <= p[i] < size[i] } + * + * or an overapproximation. */ static __isl_give isl_set *add_bounded_parameters_dynamic( __isl_take isl_set *set, __isl_keep isl_multi_pw_aff *size, @@ -1399,6 +1403,7 @@ static __isl_give isl_set *add_bounded_parameters_dynamic( size_i = isl_multi_pw_aff_get_pw_aff(size, i); bound = isl_pw_aff_lt_set(isl_pw_aff_copy(param), size_i); + bound = isl_set_from_basic_set(isl_set_simple_hull(bound)); set = isl_set_intersect_params(set, bound); zero = isl_pw_aff_zero_on_domain(isl_local_space_copy(ls)); -- 2.11.4.GIT