From f0ac917a5031316ff5ab40d1bec972a25debc04a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 22 Sep 2011 11:53:09 +0200 Subject: [PATCH] isl_set_intersect: properly handle intersection with parameter domains isl_set_intersect currently allows one of its arguments to be a parameter domain while the other is not. This will probably change in future, but while we still support this situation, we should make sure that the result lives in the same space as that of the argument that is not a parameter domain. Signed-off-by: Sven Verdoolaege --- isl_map.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/isl_map.c b/isl_map.c index 15af7ddf..571125b5 100644 --- a/isl_map.c +++ b/isl_map.c @@ -627,6 +627,17 @@ int isl_set_is_params(__isl_keep isl_set *set) return isl_space_is_params(set->dim); } +/* Is this map actually a parameter domain? + * Users should never call this function. Outside of isl, + * a map can never be a parameter domain. + */ +int isl_map_is_params(__isl_keep isl_map *map) +{ + if (!map) + return -1; + return isl_space_is_params(map->dim); +} + static struct isl_basic_map *basic_map_init(struct isl_ctx *ctx, struct isl_basic_map *bmap, unsigned extra, unsigned n_eq, unsigned n_ineq) @@ -2483,6 +2494,8 @@ static __isl_give isl_map *map_intersect(__isl_take isl_map *map1, (map1->p[0]->n_eq + map1->p[0]->n_ineq == 1 || map2->p[0]->n_eq + map2->p[0]->n_ineq == 1)) return map_intersect_add_constraint(map1, map2); + if (isl_map_is_params(map1) && !isl_map_is_params(map2)) + return isl_map_intersect(map2, map1); if (isl_space_dim(map1->dim, isl_dim_all) == isl_space_dim(map1->dim, isl_dim_param) && isl_space_dim(map2->dim, isl_dim_all) != -- 2.11.4.GIT