From c98b1bcd6b69c6bb1fb31d019c10e28cb5b2812a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 14 Oct 2012 16:38:21 +0200 Subject: [PATCH] isl_map_plain_is_disjoint: handle inputs with different parameters In particular, make sure we do not call isl_basic_map_plain_is_disjoint if the input relations do not have the same parameters. Signed-off-by: Sven Verdoolaege --- isl_map_simplify.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/isl_map_simplify.c b/isl_map_simplify.c index 90b36f4e..29c6f28c 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -2204,12 +2204,26 @@ int isl_basic_set_plain_is_disjoint(__isl_keep isl_basic_set *bset1, (struct isl_basic_map *)bset2); } +/* Are "map1" and "map2" obviously disjoint? + * + * If one of them is empty or if they live in different spaces (ignoring + * parameters), then they are clearly disjoint. + * + * If they have different parameters, then we skip any further tests. + * + * If they are obviously equal, but not obviously empty, then we will + * not be able to detect if they are disjoint. + * + * Otherwise we check if each basic map in "map1" is obviously disjoint + * from each basic map in "map2". + */ int isl_map_plain_is_disjoint(__isl_keep isl_map *map1, __isl_keep isl_map *map2) { int i, j; int disjoint; int intersect; + int match; if (!map1 || !map2) return -1; @@ -2222,6 +2236,21 @@ int isl_map_plain_is_disjoint(__isl_keep isl_map *map1, if (disjoint < 0 || disjoint) return disjoint; + match = isl_space_tuple_match(map1->dim, isl_dim_in, + map2->dim, isl_dim_in); + if (match < 0 || !match) + return match < 0 ? -1 : 1; + + match = isl_space_tuple_match(map1->dim, isl_dim_out, + map2->dim, isl_dim_out); + if (match < 0 || !match) + return match < 0 ? -1 : 1; + + match = isl_space_match(map1->dim, isl_dim_param, + map2->dim, isl_dim_param); + if (match < 0 || !match) + return match < 0 ? -1 : 0; + intersect = isl_map_plain_is_equal(map1, map2); if (intersect < 0 || intersect) return intersect < 0 ? -1 : 0; -- 2.11.4.GIT