From 5f2df0734a48dd09b890fcb6884b8b5a35e5b763 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 14 Feb 2013 18:53:43 +0100 Subject: [PATCH] isl_pw_multi_aff_drop_dims: fix dropping of output dimensions Most isl_pw_*_drop_dims functions don't support dropping of output dimensions because their pieces have a fixed single output dimension. However, the pieces of isl_pw_multi_* objects do support dropping of output dimensions and therefore so should the isl_pw_multi_*_drop_dims functions. We simply need to skip dropping dimensions from the domains. The original code would leave the result in an inconsistent state. Signed-off-by: Sven Verdoolaege --- isl_pw_templ.c | 8 +++++--- isl_test.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/isl_pw_templ.c b/isl_pw_templ.c index f112fc02..39939740 100644 --- a/isl_pw_templ.c +++ b/isl_pw_templ.c @@ -983,12 +983,14 @@ __isl_give PW *FN(PW,drop_dims)(__isl_take PW *pw, if (!pw->dim) goto error; for (i = 0; i < pw->n; ++i) { - pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n); - if (!pw->p[i].set) - goto error; pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n); if (!pw->p[i].FIELD) goto error; + if (type == isl_dim_out) + continue; + pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n); + if (!pw->p[i].set) + goto error; } return pw; diff --git a/isl_test.c b/isl_test.c index f0aee84e..82fa8d26 100644 --- a/isl_test.c +++ b/isl_test.c @@ -3750,10 +3750,40 @@ static int test_ast_gen(isl_ctx *ctx) return 0; } +/* Check if dropping output dimensions from an isl_pw_multi_aff + * works properly. + */ +static int test_pw_multi_aff(isl_ctx *ctx) +{ + const char *str; + isl_pw_multi_aff *pma1, *pma2; + int equal; + + str = "{ [i,j] -> [i+j, 4i-j] }"; + pma1 = isl_pw_multi_aff_read_from_str(ctx, str); + str = "{ [i,j] -> [4i-j] }"; + pma2 = isl_pw_multi_aff_read_from_str(ctx, str); + + pma1 = isl_pw_multi_aff_drop_dims(pma1, isl_dim_out, 0, 1); + + equal = isl_pw_multi_aff_plain_is_equal(pma1, pma2); + + isl_pw_multi_aff_free(pma1); + isl_pw_multi_aff_free(pma2); + if (equal < 0) + return -1; + if (!equal) + isl_die(ctx, isl_error_unknown, + "expressions not equal", return -1); + + return 0; +} + struct { const char *name; int (*fn)(isl_ctx *ctx); } tests [] = { + { "piecewise multi affine expressions", &test_pw_multi_aff }, { "conversion", &test_conversion }, { "list", &test_list }, { "align parameters", &test_align_parameters }, -- 2.11.4.GIT