From b2a4b83281e70199b7316297f2a8fc9bf18fe959 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 14 Jul 2011 17:48:20 +0200 Subject: [PATCH] decouple isl_aff_substitute_equalities isl_aff_substitute_equalities was being called from within two contexts: isl_pw_aff_intersect_domain and isl_aff_gist. In the first case, the space of the equalities was that of the space of the isl_pw_aff, while in the second case, the space of the equalities was a lifted copy of the _local_ space of the isl_aff. The actual implementation of isl_aff_substitute_equalities assumed the second case. Split isl_aff_substitute_equalities into two functions, one for each of these two cases. Signed-off-by: Sven Verdoolaege --- isl_aff.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/isl_aff.c b/isl_aff.c index f4f1976..5e5ea3d 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -723,7 +723,7 @@ __isl_give isl_aff *isl_aff_set_dim_name(__isl_take isl_aff *aff, * The integer divisions in this local space are assumed to appear * as regular dimensions in "eq". */ -static __isl_give isl_aff *isl_aff_substitute_equalities( +static __isl_give isl_aff *isl_aff_substitute_equalities_lifted( __isl_take isl_aff *aff, __isl_take isl_basic_set *eq) { int i, j; @@ -765,6 +765,26 @@ error: return NULL; } +/* Exploit the equalities in "eq" to simplify the affine expression + * and the expressions of the integer divisions in the local space. + */ +static __isl_give isl_aff *isl_aff_substitute_equalities( + __isl_take isl_aff *aff, __isl_take isl_basic_set *eq) +{ + int n_div; + + if (!aff || !eq) + goto error; + n_div = isl_local_space_dim(aff->ls, isl_dim_div); + if (n_div > 0) + eq = isl_basic_set_add(eq, isl_dim_set, n_div); + return isl_aff_substitute_equalities_lifted(aff, eq); +error: + isl_basic_set_free(eq); + isl_aff_free(aff); + return NULL; +} + /* Look for equalities among the variables shared by context and aff * and the integer divisions of aff, if any. * The equalities are then used to eliminate coefficients and/or integer @@ -791,7 +811,7 @@ __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff, } hull = isl_set_affine_hull(context); - return isl_aff_substitute_equalities(aff, hull); + return isl_aff_substitute_equalities_lifted(aff, hull); error: isl_aff_free(aff); isl_set_free(context); -- 2.7.4