From 8c20d21a02f489a6489e5ab905f965dfc3ca2f0a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 7 Jul 2011 21:16:03 +0200 Subject: [PATCH] add isl_pw_aff_lt_set and isl_pw_aff_gt_set Signed-off-by: Sven Verdoolaege --- doc/user.pod | 6 ++++++ include/isl/aff.h | 4 ++++ isl_aff.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index 914e625..d9a78ea 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2370,9 +2370,15 @@ 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_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, __isl_take isl_pw_aff *pwaff2); + __isl_give isl_set *isl_pw_aff_gt_set( + __isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2); The function C returns a basic set containing those elements in the shared space diff --git a/include/isl/aff.h b/include/isl/aff.h index 613bcb3..9b8a917 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -121,8 +121,12 @@ __isl_give isl_pw_aff *isl_pw_aff_gist(__isl_take isl_pw_aff *pwaff, __isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff); +__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, __isl_take isl_pw_aff *pwaff2); +__isl_give isl_set *isl_pw_aff_gt_set(__isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2); __isl_give isl_printer *isl_printer_print_pw_aff(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff); diff --git a/isl_aff.c b/isl_aff.c index ed66c74..69ab36e 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -1,11 +1,14 @@ /* * Copyright 2011 INRIA Saclay + * Copyright 2011 Universiteit Leiden * * Use of this software is governed by the GNU LGPLv2.1 license * * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, * 91893 Orsay, France + * and Leiden Institute of Advanced Computer Science, + * Universiteit Leiden, Niels Bohrweg 1, 2333 CA Leiden, The Netherlands */ #include @@ -1081,10 +1084,14 @@ __isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff) } /* Return a set containing those elements in the shared domain - * of pwaff1 and pwaff2 where pwaff1 is greater than or equal to pwaff2. + * 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. */ -__isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, - __isl_take isl_pw_aff *pwaff2) +static __isl_give isl_set *pw_aff_gte_set(__isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2, int strict) { isl_set *set1, *set2; @@ -1092,8 +1099,41 @@ __isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, set2 = isl_pw_aff_domain(isl_pw_aff_copy(pwaff2)); set1 = isl_set_intersect(set1, set2); pwaff1 = isl_pw_aff_intersect_domain(pwaff1, isl_set_copy(set1)); - pwaff2 = isl_pw_aff_intersect_domain(pwaff2, set1); + pwaff2 = isl_pw_aff_intersect_domain(pwaff2, isl_set_copy(set1)); pwaff1 = isl_pw_aff_add(pwaff1, isl_pw_aff_neg(pwaff2)); + if (strict) { + isl_dim *dim = isl_set_get_dim(set1); + isl_aff *aff; + aff = isl_aff_zero(isl_local_space_from_dim(dim)); + aff = isl_aff_add_constant_si(aff, -1); + pwaff1 = isl_pw_aff_add(pwaff1, isl_pw_aff_alloc(set1, aff)); + } else + isl_set_free(set1); + return isl_pw_aff_nonneg_set(pwaff1); } + +/* 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 a set containing those elements in the shared domain + * of pwaff1 and pwaff2 where pwaff1 is strictly greater than pwaff2. + */ +__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); +} + +__isl_give isl_set *isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2) +{ + return isl_pw_aff_gt_set(pwaff2, pwaff1); +} -- 2.7.4