This extends isl_map_domain_reverse to union maps.
Signed-off-by: Sven Verdoolaege <sven@cerebras.net>
@@ -5457,6 +5457,8 @@ earlier dimensions before those that involve later dimensions.
#include <isl/union_map.h>
__isl_give isl_union_map *isl_union_map_reverse(
__isl_take isl_union_map *umap);
+ __isl_give isl_union_map *isl_union_map_domain_reverse(
+ __isl_take isl_union_map *umap);
__isl_give isl_union_map *isl_union_map_range_reverse(
__isl_take isl_union_map *umap);
@@ -227,6 +227,9 @@ __isl_give isl_union_map *isl_union_map_preimage_range_union_pw_multi_aff(
__isl_export
__isl_give isl_union_map *isl_union_map_reverse(__isl_take isl_union_map *umap);
__isl_export
+__isl_give isl_union_map *isl_union_map_domain_reverse(
+ __isl_take isl_union_map *umap);
+__isl_export
__isl_give isl_union_map *isl_union_map_range_reverse(
__isl_take isl_union_map *umap);
__isl_export
@@ -513,6 +513,17 @@ static void test_reverse(isl::ctx ctx)
"{ N[B[*] -> B[*]] -> A[] }" },
});
+ C(&isl::union_map::domain_reverse, {
+ { "{ [A[] -> B[]] -> [C[] -> D[]] }",
+ "{ [B[] -> A[]] -> [C[] -> D[]] }" },
+ { "{ A[] -> [B[] -> C[]]; A[] -> B[]; A[0] -> N[B[1] -> B[2]] }",
+ "{ }" },
+ { "{ N[B[] -> C[]] -> A[] }",
+ "{ [C[] -> B[]] -> A[] }" },
+ { "{ N[B[x] -> B[y]] -> A[] }",
+ "{ N[B[*] -> B[*]] -> A[] }" },
+ });
+
C(&isl::union_map::range_reverse, {
{ "{ A[] -> [B[] -> C[]]; A[] -> B[]; A[0] -> N[B[1] -> B[2]] }",
"{ A[] -> [C[] -> B[]]; A[0] -> N[B[2] -> B[1]] }" },
* Copyright 2013-2014 Ecole Normale Superieure
* Copyright 2014 INRIA Rocquencourt
* Copyright 2016-2017 Sven Verdoolaege
+ * Copyright 2022 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* 91893 Orsay, France
* and Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt,
* B.P. 105 - 78153 Le Chesnay, France
+ * and Cerebras Systems, 1237 E Arques Ave, Sunnyvale, CA, USA
*/
#include <isl_map_private.h>
@@ -2317,6 +2319,21 @@ __isl_give isl_union_map *isl_union_map_reverse(__isl_take isl_union_map *umap)
return un_op(umap, &control);
}
+/* Given a union map, take the maps of the form (A -> B) -> C and
+ * return the union of the corresponding maps (B -> A) -> C.
+ */
+__isl_give isl_union_map *isl_union_map_domain_reverse(
+ __isl_take isl_union_map *umap)
+{
+ struct isl_un_op_drop_user_data data = { &isl_map_domain_is_wrapping };
+ struct isl_un_op_control control = {
+ .filter = &un_op_filter_drop_user,
+ .filter_user = &data,
+ .fn_map = &isl_map_domain_reverse,
+ };
+ return un_op(umap, &control);
+}
+
/* Given a union map, take the maps of the form A -> (B -> C) and
* return the union of the corresponding maps A -> (C -> B).
*/