From 732fdbd0b5857a367bd7677f6756fe7d28841653 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 17 Jan 2012 13:52:09 +0100 Subject: [PATCH] isl_pw_aff_non_zero_set: don't assume isl_pw_aff is total Before, we would return the domain where the function is not zero or undefined, whereas we should only return the domain where the function is not zero. Signed-off-by: Sven Verdoolaege --- isl_aff.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/isl_aff.c b/isl_aff.c index 42000ce..ca86174 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -1478,9 +1478,11 @@ __isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff) } /* Return a set containing those elements in the domain - * of pwaff where it is zero. + * of pwaff where it is zero (if complement is 0) or not zero + * (if complement is 1). */ -__isl_give isl_set *isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff) +static __isl_give isl_set *pw_aff_zero_set(__isl_take isl_pw_aff *pwaff, + int complement) { int i; isl_set *set; @@ -1492,11 +1494,15 @@ __isl_give isl_set *isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff) for (i = 0; i < pwaff->n; ++i) { isl_basic_set *bset; - isl_set *set_i; + isl_set *set_i, *zero; bset = isl_aff_zero_basic_set(isl_aff_copy(pwaff->p[i].aff)); - set_i = isl_set_from_basic_set(bset); - set_i = isl_set_intersect(set_i, isl_set_copy(pwaff->p[i].set)); + zero = isl_set_from_basic_set(bset); + set_i = isl_set_copy(pwaff->p[i].set); + if (complement) + set_i = isl_set_subtract(set_i, zero); + else + set_i = isl_set_intersect(set_i, zero); set = isl_set_union_disjoint(set, set_i); } @@ -1506,11 +1512,19 @@ __isl_give isl_set *isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff) } /* Return a set containing those elements in the domain + * of pwaff where it is zero. + */ +__isl_give isl_set *isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff) +{ + return pw_aff_zero_set(pwaff, 0); +} + +/* Return a set containing those elements in the domain * of pwaff where it is not zero. */ __isl_give isl_set *isl_pw_aff_non_zero_set(__isl_take isl_pw_aff *pwaff) { - return isl_set_complement(isl_pw_aff_zero_set(pwaff)); + return pw_aff_zero_set(pwaff, 1); } /* Return a set containing those elements in the shared domain -- 2.7.4