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;
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;
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 },