From ae98bffd792452c76ed3be8a42356cc92ac30c21 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 27 Feb 2013 14:42:44 +0100 Subject: [PATCH] isl_basic_map_curry: add missing isl_basic_map_cow Signed-off-by: Sven Verdoolaege --- isl_map.c | 3 +++ isl_test.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/isl_map.c b/isl_map.c index 51a8600b..085bbb4c 100644 --- a/isl_map.c +++ b/isl_map.c @@ -10389,6 +10389,9 @@ __isl_give isl_basic_map *isl_basic_map_curry(__isl_take isl_basic_map *bmap) if (!isl_basic_map_can_curry(bmap)) isl_die(bmap->ctx, isl_error_invalid, "basic map cannot be curried", goto error); + bmap = isl_basic_map_cow(bmap); + if (!bmap) + return NULL; bmap->dim = isl_space_curry(bmap->dim); if (!bmap->dim) goto error; diff --git a/isl_test.c b/isl_test.c index 82fa8d26..8f03ddb1 100644 --- a/isl_test.c +++ b/isl_test.c @@ -3303,6 +3303,31 @@ static int test_conversion(isl_ctx *ctx) return 0; } +/* Check that isl_basic_map_curry does not modify input. + */ +static int test_curry(isl_ctx *ctx) +{ + const char *str; + isl_basic_map *bmap1, *bmap2; + int equal; + + str = "{ [A[] -> B[]] -> C[] }"; + bmap1 = isl_basic_map_read_from_str(ctx, str); + bmap2 = isl_basic_map_curry(isl_basic_map_copy(bmap1)); + equal = isl_basic_map_is_equal(bmap1, bmap2); + isl_basic_map_free(bmap1); + isl_basic_map_free(bmap2); + + if (equal < 0) + return -1; + if (equal) + isl_die(ctx, isl_error_unknown, + "curried map should not be equal to original", + return -1); + + return 0; +} + struct { const char *set; const char *ma; @@ -3783,6 +3808,7 @@ struct { const char *name; int (*fn)(isl_ctx *ctx); } tests [] = { + { "curry", &test_curry }, { "piecewise multi affine expressions", &test_pw_multi_aff }, { "conversion", &test_conversion }, { "list", &test_list }, -- 2.11.4.GIT