From 6dc44e197e8a6af231978a38a03f08c10dd4ceb6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 9 Jul 2011 12:28:59 +0200 Subject: [PATCH] add isl_pw_aff_eq_set Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/aff.h | 2 ++ isl_aff.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index b1e6e53f..2e2257b9 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2389,6 +2389,9 @@ Operations include __isl_give isl_basic_set *isl_aff_ge_basic_set( __isl_take isl_aff *aff1, __isl_take isl_aff *aff2); + __isl_give isl_set *isl_pw_aff_eq_set( + __isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2); __isl_give isl_set *isl_pw_aff_lt_set( __isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2); diff --git a/include/isl/aff.h b/include/isl/aff.h index 7007443b..30301b99 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -136,6 +136,8 @@ __isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff); __isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff); +__isl_give isl_set *isl_pw_aff_eq_set(__isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2); __isl_give isl_set *isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2); __isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, diff --git a/isl_aff.c b/isl_aff.c index 82d9a556..0f2102de 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -810,6 +810,18 @@ __isl_give isl_basic_set *isl_aff_nonneg_basic_set(__isl_take isl_aff *aff) return isl_basic_set_from_constraint(ineq); } +/* Return a basic set containing those elements in the space + * of aff where it is zero. + */ +__isl_give isl_basic_set *isl_aff_zero_basic_set(__isl_take isl_aff *aff) +{ + isl_constraint *ineq; + + ineq = isl_equality_from_aff(aff); + + return isl_basic_set_from_constraint(ineq); +} + /* Return a basic set containing those elements in the shared space * of aff1 and aff2 where aff1 is greater than or equal to aff2. */ @@ -1152,15 +1164,45 @@ __isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff) return set; } +/* 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) +{ + int i; + isl_set *set; + + if (!pwaff) + return NULL; + + set = isl_set_empty(isl_pw_aff_get_dim(pwaff)); + + for (i = 0; i < pwaff->n; ++i) { + isl_basic_set *bset; + isl_set *set_i; + + 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)); + set = isl_set_union_disjoint(set, set_i); + } + + isl_pw_aff_free(pwaff); + + return set; +} + /* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is greater than (or equal) to pwaff2. * * We compute the difference on the shared domain and then construct * the set of values where this difference is non-negative. * If strict is set, we first subtract 1 from the difference. + * If equal is set, we only return the elements where pwaff1 and pwaff2 + * are equal. */ static __isl_give isl_set *pw_aff_gte_set(__isl_take isl_pw_aff *pwaff1, - __isl_take isl_pw_aff *pwaff2, int strict) + __isl_take isl_pw_aff *pwaff2, int strict, int equal) { isl_set *set1, *set2; @@ -1180,16 +1222,27 @@ static __isl_give isl_set *pw_aff_gte_set(__isl_take isl_pw_aff *pwaff1, } else isl_set_free(set1); + if (equal) + return isl_pw_aff_zero_set(pwaff1); return isl_pw_aff_nonneg_set(pwaff1); } /* Return a set containing those elements in the shared domain + * of pwaff1 and pwaff2 where pwaff1 is equal to pwaff2. + */ +__isl_give isl_set *isl_pw_aff_eq_set(__isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2) +{ + return pw_aff_gte_set(pwaff1, pwaff2, 0, 1); +} + +/* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is greater than or equal to pwaff2. */ __isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { - return pw_aff_gte_set(pwaff1, pwaff2, 0); + return pw_aff_gte_set(pwaff1, pwaff2, 0, 0); } /* Return a set containing those elements in the shared domain @@ -1198,7 +1251,7 @@ __isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, __isl_give isl_set *isl_pw_aff_gt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { - return pw_aff_gte_set(pwaff1, pwaff2, 1); + return pw_aff_gte_set(pwaff1, pwaff2, 1, 0); } __isl_give isl_set *isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, -- 2.11.4.GIT