isl_ast_graft.c: store_guard: coalesce guard after taking gist
[platform/upstream/isl.git] / isl_union_map.c
index bb82de7..ed6639f 100644 (file)
@@ -41,6 +41,7 @@ static __isl_give isl_union_map *isl_union_map_alloc(__isl_take isl_space *dim,
 {
        isl_union_map *umap;
 
+       dim = isl_space_params(dim);
        if (!dim)
                return NULL;
 
@@ -2394,6 +2395,27 @@ __isl_give isl_union_map *isl_union_map_zip(__isl_take isl_union_map *umap)
        return cond_un_op(umap, &zip_entry);
 }
 
+static int uncurry_entry(void **entry, void *user)
+{
+       isl_map *map = *entry;
+       isl_union_map **res = user;
+
+       if (!isl_map_can_uncurry(map))
+               return 0;
+
+       *res = isl_union_map_add_map(*res, isl_map_uncurry(isl_map_copy(map)));
+
+       return 0;
+}
+
+/* Given a union map, take the maps of the form A -> (B -> C) and
+ * return the union of the corresponding maps (A -> B) -> C.
+ */
+__isl_give isl_union_map *isl_union_map_uncurry(__isl_take isl_union_map *umap)
+{
+       return cond_un_op(umap, &uncurry_entry);
+}
+
 static int curry_entry(void **entry, void *user)
 {
        isl_map *map = *entry;