isl_map_plain_is_disjoint: handle inputs with different parameters
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 14 Oct 2012 14:38:21 +0000 (16:38 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 14 Oct 2012 14:38:21 +0000 (16:38 +0200)
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 <skimo@kotnet.org>
isl_map_simplify.c

index 90b36f4..29c6f28 100644 (file)
@@ -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;