return NULL;
}
+/* Return a map that has the same intersection with "context" as "map"
+ * and that as "simple" as possible.
+ *
+ * If "map" is already the universe, then we cannot make it any simpler.
+ * Similarly, if "context" is the universe, then we cannot exploit it
+ * to simplify "map"
+ * If "map" and "context" are identical to each other, then we can
+ * return the corresponding universe.
+ *
+ * If none of these cases apply, we have to work a bit harder.
+ */
static __isl_give isl_map *map_gist(__isl_take isl_map *map,
__isl_take isl_map *context)
{
+ int equal;
+ int is_universe;
+
+ is_universe = isl_map_plain_is_universe(map);
+ if (is_universe >= 0 && !is_universe)
+ is_universe = isl_map_plain_is_universe(context);
+ if (is_universe < 0)
+ goto error;
+ if (is_universe) {
+ isl_map_free(context);
+ return map;
+ }
+
+ equal = isl_map_plain_is_equal(map, context);
+ if (equal < 0)
+ goto error;
+ if (equal) {
+ isl_map *res = isl_map_universe(isl_map_get_space(map));
+ isl_map_free(map);
+ isl_map_free(context);
+ return res;
+ }
+
context = isl_map_compute_divs(context);
return isl_map_gist_basic_map(map, isl_map_simple_hull(context));
+error:
+ isl_map_free(map);
+ isl_map_free(context);
+ return NULL;
}
__isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
__isl_keep isl_map *map2)
{
int i, j;
+ int disjoint;
+ int intersect;
if (!map1 || !map2)
return -1;
- if (isl_map_plain_is_equal(map1, map2))
- return 0;
+ disjoint = isl_map_plain_is_empty(map1);
+ if (disjoint < 0 || disjoint)
+ return disjoint;
+
+ disjoint = isl_map_plain_is_empty(map2);
+ if (disjoint < 0 || disjoint)
+ return disjoint;
+
+ intersect = isl_map_plain_is_equal(map1, map2);
+ if (intersect < 0 || intersect)
+ return intersect < 0 ? -1 : 0;
for (i = 0; i < map1->n; ++i) {
for (j = 0; j < map2->n; ++j) {
return 1;
}
+/* Are "map1" and "map2" disjoint?
+ *
+ * They are disjoint if they are "obviously disjoint" or if one of them
+ * is empty. Otherwise, they are not disjoint if one of them is universal.
+ * If none of these cases apply, we compute the intersection and see if
+ * the result is empty.
+ */
+int isl_map_is_disjoint(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
+{
+ int disjoint;
+ int intersect;
+ isl_map *test;
+
+ disjoint = isl_map_plain_is_disjoint(map1, map2);
+ if (disjoint < 0 || disjoint)
+ return disjoint;
+
+ disjoint = isl_map_is_empty(map1);
+ if (disjoint < 0 || disjoint)
+ return disjoint;
+
+ disjoint = isl_map_is_empty(map2);
+ if (disjoint < 0 || disjoint)
+ return disjoint;
+
+ intersect = isl_map_plain_is_universe(map1);
+ if (intersect < 0 || intersect)
+ return intersect < 0 ? -1 : 0;
+
+ intersect = isl_map_plain_is_universe(map2);
+ if (intersect < 0 || intersect)
+ return intersect < 0 ? -1 : 0;
+
+ test = isl_map_intersect(isl_map_copy(map1), isl_map_copy(map2));
+ disjoint = isl_map_is_empty(test);
+ isl_map_free(test);
+
+ return disjoint;
+}
+
int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
__isl_keep isl_set *set2)
{
(struct isl_map *)set2);
}
+/* Are "set1" and "set2" disjoint?
+ */
+int isl_set_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
+{
+ return isl_map_is_disjoint(set1, set2);
+}
+
int isl_set_fast_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
{
return isl_set_plain_is_disjoint(set1, set2);