isl_multi_*: store pieces in a union
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Mon, 16 Oct 2017 13:08:00 +0000 (16 15:08 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Sun, 4 Mar 2018 14:36:00 +0000 (4 15:36 +0100)
In particular, only consider the field representing the pieces
to be valid when the number of base expressions is greater than zero.
Since the field is only used to access a base expression,
it is never used when the number of base expression is zero.
Making this condition more explicit allows the field
to overlap with the domain of a zero-dimensional expression,
which will be introduced in an upcoming commit.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
14 files changed:
isl_aff.c
isl_local_space.c
isl_map.c
isl_multi_apply_templ.c
isl_multi_cmp.c
isl_multi_coalesce.c
isl_multi_dims.c
isl_multi_floor.c
isl_multi_hash.c
isl_multi_templ.c
isl_multi_templ.h
isl_output.c
isl_tab_pip.c
isl_val.c

index bec3796..bab1866 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -3350,7 +3350,7 @@ isl_bool isl_multi_pw_aff_is_cst(__isl_keep isl_multi_pw_aff *mpa)
                return isl_bool_error;
 
        for (i = 0; i < mpa->n; ++i) {
-               isl_bool is_cst = isl_pw_aff_is_cst(mpa->p[i]);
+               isl_bool is_cst = isl_pw_aff_is_cst(mpa->u.p[i]);
                if (is_cst < 0 || !is_cst)
                        return is_cst;
        }
@@ -4111,9 +4111,9 @@ static __isl_give isl_multi_aff *isl_multi_aff_substitute_equalities(
                goto error;
 
        for (i = 0; i < maff->n; ++i) {
-               maff->p[i] = isl_aff_substitute_equalities(maff->p[i],
+               maff->u.p[i] = isl_aff_substitute_equalities(maff->u.p[i],
                                                    isl_basic_set_copy(eq));
-               if (!maff->p[i])
+               if (!maff->u.p[i])
                        goto error;
        }
 
@@ -4135,8 +4135,8 @@ __isl_give isl_multi_aff *isl_multi_aff_scale(__isl_take isl_multi_aff *maff,
                return NULL;
 
        for (i = 0; i < maff->n; ++i) {
-               maff->p[i] = isl_aff_scale(maff->p[i], f);
-               if (!maff->p[i])
+               maff->u.p[i] = isl_aff_scale(maff->u.p[i], f);
+               if (!maff->u.p[i])
                        return isl_multi_aff_free(maff);
        }
 
@@ -5396,8 +5396,9 @@ __isl_give isl_multi_aff *isl_multi_aff_substitute(
                type = isl_dim_set;
 
        for (i = 0; i < maff->n; ++i) {
-               maff->p[i] = isl_aff_substitute(maff->p[i], type, pos, subs);
-               if (!maff->p[i])
+               maff->u.p[i] = isl_aff_substitute(maff->u.p[i],
+                                               type, pos, subs);
+               if (!maff->u.p[i])
                        return isl_multi_aff_free(maff);
        }
 
@@ -5538,7 +5539,7 @@ void isl_seq_preimage(isl_int *dst, isl_int *src,
 
                if (isl_int_is_zero(src[offset]))
                        continue;
-               isl_int_set(c1, ma->p[i]->v->el[0]);
+               isl_int_set(c1, ma->u.p[i]->v->el[0]);
                isl_int_mul(c2, f, src[offset]);
                isl_int_gcd(g, c1, c2);
                isl_int_divexact(c1, c1, g);
@@ -5548,19 +5549,19 @@ void isl_seq_preimage(isl_int *dst, isl_int *src,
                o_dst = has_denom;
                o_src = 1;
                isl_seq_combine(dst + o_dst, c1, dst + o_dst,
-                               c2, ma->p[i]->v->el + o_src, 1 + n_param);
+                               c2, ma->u.p[i]->v->el + o_src, 1 + n_param);
                o_dst += 1 + n_param;
                o_src += 1 + n_param;
                isl_seq_scale(dst + o_dst, dst + o_dst, c1, n_before);
                o_dst += n_before;
                isl_seq_combine(dst + o_dst, c1, dst + o_dst,
-                               c2, ma->p[i]->v->el + o_src, n_in);
+                               c2, ma->u.p[i]->v->el + o_src, n_in);
                o_dst += n_in;
                o_src += n_in;
                isl_seq_scale(dst + o_dst, dst + o_dst, c1, n_after);
                o_dst += n_after;
                isl_seq_combine(dst + o_dst, c1, dst + o_dst,
-                               c2, ma->p[i]->v->el + o_src, n_div_ma);
+                               c2, ma->u.p[i]->v->el + o_src, n_div_ma);
                o_dst += n_div_ma;
                o_src += n_div_ma;
                isl_seq_scale(dst + o_dst, dst + o_dst, c1, n_div_bmap);
@@ -5601,7 +5602,7 @@ __isl_give isl_aff *isl_aff_pullback_multi_aff(__isl_take isl_aff *aff,
                goto error;
 
        n_div_aff = isl_aff_dim(aff, isl_dim_div);
-       n_div_ma = ma->n ? isl_aff_dim(ma->p[0], isl_dim_div) : 0;
+       n_div_ma = ma->n ? isl_aff_dim(ma->u.p[0], isl_dim_div) : 0;
 
        ls = isl_aff_get_domain_local_space(aff);
        ls = isl_local_space_preimage_multi_aff(ls, isl_multi_aff_copy(ma));
@@ -5669,9 +5670,9 @@ static __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff_aligned(
                                isl_multi_aff_get_space(ma1));
 
        for (i = 0; i < ma1->n; ++i) {
-               ma1->p[i] = isl_aff_pullback_multi_aff(ma1->p[i],
+               ma1->u.p[i] = isl_aff_pullback_multi_aff(ma1->u.p[i],
                                                    isl_multi_aff_copy(ma2));
-               if (!ma1->p[i])
+               if (!ma1->u.p[i])
                        goto error;
        }
 
@@ -5766,10 +5767,10 @@ __isl_give isl_multi_aff *isl_multi_aff_align_divs(
                return NULL;
 
        for (i = 1; i < maff->n; ++i)
-               maff->p[0] = isl_aff_align_divs(maff->p[0], maff->p[i]);
+               maff->u.p[0] = isl_aff_align_divs(maff->u.p[0], maff->u.p[i]);
        for (i = 1; i < maff->n; ++i) {
-               maff->p[i] = isl_aff_align_divs(maff->p[i], maff->p[0]);
-               if (!maff->p[i])
+               maff->u.p[i] = isl_aff_align_divs(maff->u.p[i], maff->u.p[0]);
+               if (!maff->u.p[i])
                        return isl_multi_aff_free(maff);
        }
 
@@ -5822,7 +5823,7 @@ __isl_give isl_multi_aff *isl_multi_aff_lift(__isl_take isl_multi_aff *maff,
        if (!maff)
                return NULL;
 
-       n_div = isl_aff_dim(maff->p[0], isl_dim_div);
+       n_div = isl_aff_dim(maff->u.p[0], isl_dim_div);
        space = isl_multi_aff_get_space(maff);
        space = isl_space_lift(isl_space_domain(space), n_div);
        space = isl_space_extend_domain_with_range(space,
@@ -5833,14 +5834,14 @@ __isl_give isl_multi_aff *isl_multi_aff_lift(__isl_take isl_multi_aff *maff,
        maff->space = space;
 
        if (ls) {
-               *ls = isl_aff_get_domain_local_space(maff->p[0]);
+               *ls = isl_aff_get_domain_local_space(maff->u.p[0]);
                if (!*ls)
                        return isl_multi_aff_free(maff);
        }
 
        for (i = 0; i < maff->n; ++i) {
-               maff->p[i] = isl_aff_lift(maff->p[i]);
-               if (!maff->p[i])
+               maff->u.p[i] = isl_aff_lift(maff->u.p[i]);
+               if (!maff->u.p[i])
                        goto error;
        }
 
@@ -6434,7 +6435,7 @@ static __isl_give isl_map *map_from_multi_pw_aff(
                isl_pw_aff *pa;
                isl_map *map_i;
 
-               pa = isl_pw_aff_copy(mpa->p[i]);
+               pa = isl_pw_aff_copy(mpa->u.p[i]);
                map_i = map_from_pw_aff(pa);
 
                map = isl_map_flat_range_product(map, map_i);
@@ -6657,7 +6658,7 @@ isl_bool isl_multi_pw_aff_is_equal(__isl_keep isl_multi_pw_aff *mpa1,
                return equal;
 
        for (i = 0; i < mpa1->n; ++i) {
-               equal = isl_pw_aff_is_equal(mpa1->p[i], mpa2->p[i]);
+               equal = isl_pw_aff_is_equal(mpa1->u.p[i], mpa2->u.p[i]);
                if (equal < 0 || !equal)
                        return equal;
        }
@@ -6723,9 +6724,9 @@ static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_pullback_multi_aff_aligned(
                goto error;
 
        for (i = 0; i < mpa->n; ++i) {
-               mpa->p[i] = isl_pw_aff_pullback_multi_aff(mpa->p[i],
+               mpa->u.p[i] = isl_pw_aff_pullback_multi_aff(mpa->u.p[i],
                                                    isl_multi_aff_copy(ma));
-               if (!mpa->p[i])
+               if (!mpa->u.p[i])
                        goto error;
        }
 
@@ -6784,9 +6785,9 @@ isl_multi_pw_aff_pullback_pw_multi_aff_aligned(
                                isl_multi_pw_aff_get_space(mpa));
 
        for (i = 0; i < mpa->n; ++i) {
-               mpa->p[i] = isl_pw_aff_pullback_pw_multi_aff_aligned(mpa->p[i],
-                                                   isl_pw_multi_aff_copy(pma));
-               if (!mpa->p[i])
+               mpa->u.p[i] = isl_pw_aff_pullback_pw_multi_aff_aligned(
+                                   mpa->u.p[i], isl_pw_multi_aff_copy(pma));
+               if (!mpa->u.p[i])
                        goto error;
        }
 
@@ -7035,9 +7036,9 @@ isl_multi_pw_aff_pullback_multi_pw_aff_aligned(
                                isl_multi_pw_aff_get_space(mpa1));
 
        for (i = 0; i < mpa1->n; ++i) {
-               mpa1->p[i] = isl_pw_aff_pullback_multi_pw_aff_aligned(
-                               mpa1->p[i], isl_multi_pw_aff_copy(mpa2));
-               if (!mpa1->p[i])
+               mpa1->u.p[i] = isl_pw_aff_pullback_multi_pw_aff_aligned(
+                               mpa1->u.p[i], isl_multi_pw_aff_copy(mpa2));
+               if (!mpa1->u.p[i])
                        goto error;
        }
 
index bc5861f..bd672b3 100644 (file)
@@ -1344,7 +1344,7 @@ __isl_give isl_local_space *isl_local_space_preimage_multi_aff(
                        "spaces don't match", goto error);
 
        n_div_ls = isl_local_space_dim(ls, isl_dim_div);
-       n_div_ma = ma->n ? isl_aff_dim(ma->p[0], isl_dim_div) : 0;
+       n_div_ma = ma->n ? isl_aff_dim(ma->u.p[0], isl_dim_div) : 0;
 
        space = isl_space_domain(isl_multi_aff_get_space(ma));
        res = isl_local_space_alloc(space, n_div_ma + n_div_ls);
@@ -1353,7 +1353,7 @@ __isl_give isl_local_space *isl_local_space_preimage_multi_aff(
 
        if (n_div_ma) {
                isl_mat_free(res->div);
-               res->div = isl_mat_copy(ma->p[0]->ls->div);
+               res->div = isl_mat_copy(ma->u.p[0]->ls->div);
                res->div = isl_mat_add_zero_cols(res->div, n_div_ls);
                res->div = isl_mat_add_rows(res->div, n_div_ls);
                if (!res->div)
index 47e7acd..da41875 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -12231,7 +12231,7 @@ __isl_give isl_basic_map *isl_basic_map_from_multi_aff2(
                isl_aff *aff;
                isl_basic_map *bmap_i;
 
-               aff = isl_aff_copy(maff->p[i]);
+               aff = isl_aff_copy(maff->u.p[i]);
                bmap_i = isl_basic_map_from_aff2(aff, rational);
 
                bmap = isl_basic_map_flat_range_product(bmap, bmap_i);
@@ -12762,7 +12762,7 @@ static int set_ma_divs(__isl_keep isl_basic_map *bmap,
        if (n_div == 0)
                return 0;
 
-       ls = isl_aff_get_domain_local_space(ma->p[0]);
+       ls = isl_aff_get_domain_local_space(ma->u.p[0]);
        if (!ls)
                return -1;
 
@@ -12808,7 +12808,7 @@ static int multi_aff_strides(__isl_keep isl_multi_aff *ma)
        int strides = 0;
 
        for (i = 0; i < ma->n; ++i)
-               if (!isl_int_is_one(ma->p[i]->v->el[0]))
+               if (!isl_int_is_one(ma->u.p[i]->v->el[0]))
                        strides++;
 
        return strides;
@@ -12848,7 +12848,7 @@ static __isl_give isl_basic_map *add_ma_strides(
        for (i = 0; i < ma->n; ++i) {
                int o_bmap = 0, o_ma = 1;
 
-               if (isl_int_is_one(ma->p[i]->v->el[0]))
+               if (isl_int_is_one(ma->u.p[i]->v->el[0]))
                        continue;
                div = isl_basic_map_alloc_div(bmap);
                k = isl_basic_map_alloc_equality(bmap);
@@ -12856,23 +12856,23 @@ static __isl_give isl_basic_map *add_ma_strides(
                        goto error;
                isl_int_set_si(bmap->div[div][0], 0);
                isl_seq_cpy(bmap->eq[k] + o_bmap,
-                           ma->p[i]->v->el + o_ma, 1 + n_param);
+                           ma->u.p[i]->v->el + o_ma, 1 + n_param);
                o_bmap += 1 + n_param;
                o_ma += 1 + n_param;
                isl_seq_clr(bmap->eq[k] + o_bmap, n_before);
                o_bmap += n_before;
                isl_seq_cpy(bmap->eq[k] + o_bmap,
-                           ma->p[i]->v->el + o_ma, n_in);
+                           ma->u.p[i]->v->el + o_ma, n_in);
                o_bmap += n_in;
                o_ma += n_in;
                isl_seq_clr(bmap->eq[k] + o_bmap, n_after);
                o_bmap += n_after;
                isl_seq_cpy(bmap->eq[k] + o_bmap,
-                           ma->p[i]->v->el + o_ma, n_div_ma);
+                           ma->u.p[i]->v->el + o_ma, n_div_ma);
                o_bmap += n_div_ma;
                o_ma += n_div_ma;
                isl_seq_clr(bmap->eq[k] + o_bmap, 1 + total - o_bmap);
-               isl_int_neg(bmap->eq[k][1 + total], ma->p[i]->v->el[0]);
+               isl_int_neg(bmap->eq[k][1 + total], ma->u.p[i]->v->el[0]);
                total++;
        }
 
@@ -12975,7 +12975,7 @@ __isl_give isl_basic_map *isl_basic_map_preimage_multi_aff(
                n_after = 0;
        }
        n_div_bmap = isl_basic_map_dim(bmap, isl_dim_div);
-       n_div_ma = ma->n ? isl_aff_dim(ma->p[0], isl_dim_div) : 0;
+       n_div_ma = ma->n ? isl_aff_dim(ma->u.p[0], isl_dim_div) : 0;
 
        space = isl_multi_aff_get_domain_space(ma);
        space = isl_space_set(isl_basic_map_get_space(bmap), type, space);
index 44fcb9a..870f267 100644 (file)
@@ -34,8 +34,8 @@ __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),apply_aligned),APPLY_DOMBASE)(
                goto error;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = fn(multi->p[i], FN(APPLY_DOM,copy)(set));
-               if (!multi->p[i])
+               multi->u.p[i] = fn(multi->u.p[i], FN(APPLY_DOM,copy)(set));
+               if (!multi->u.p[i])
                        goto error;
        }
 
index a99d370..27ab6dc 100644 (file)
@@ -31,7 +31,7 @@ int FN(MULTI(BASE),plain_cmp)(__isl_keep MULTI(BASE) *multi1,
                return cmp;
 
        for (i = 0; i < multi1->n; ++i) {
-               cmp = FN(EL,plain_cmp)(multi1->p[i], multi2->p[i]);
+               cmp = FN(EL,plain_cmp)(multi1->u.p[i], multi2->u.p[i]);
                if (cmp != 0)
                        return cmp;
        }
index aef59e8..588e107 100644 (file)
@@ -23,12 +23,12 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),coalesce)(__isl_take MULTI(BASE) *multi)
                return NULL;
 
        for (i = 0; i < multi->n; ++i) {
-               EL *el = FN(EL,copy)(multi->p[i]);
+               EL *el = FN(EL,copy)(multi->u.p[i]);
                el = FN(EL,coalesce)(el);
                if (!el)
                        return FN(MULTI(BASE),free)(multi);
-               FN(EL,free)(multi->p[i]);
-               multi->p[i] = el;
+               FN(EL,free)(multi->u.p[i]);
+               multi->u.p[i] = el;
        }
 
        return multi;
index 93e98ad..7bfa386 100644 (file)
@@ -29,7 +29,7 @@ isl_bool FN(MULTI(BASE),involves_dims)(__isl_keep MULTI(BASE) *multi,
        for (i = 0; i < multi->n; ++i) {
                isl_bool involves;
 
-               involves = FN(EL,involves_dims)(multi->p[i], type, first, n);
+               involves = FN(EL,involves_dims)(multi->u.p[i], type, first, n);
                if (involves < 0 || involves)
                        return involves;
        }
@@ -61,8 +61,9 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),insert_dims)(
                return FN(MULTI(BASE),free)(multi);
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,insert_dims)(multi->p[i], type, first, n);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,insert_dims)(multi->u.p[i],
+                                                       type, first, n);
+               if (!multi->u.p[i])
                        return FN(MULTI(BASE),free)(multi);
        }
 
index d869e65..b9a8898 100644 (file)
@@ -20,8 +20,8 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),floor)(__isl_take MULTI(BASE) *multi)
                return NULL;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,floor)(multi->p[i]);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,floor)(multi->u.p[i]);
+               if (!multi->u.p[i])
                        return FN(MULTI(BASE),free)(multi);
        }
 
index b4bb6c3..0c7ebdf 100644 (file)
@@ -22,7 +22,7 @@ uint32_t FN(MULTI(BASE),get_hash)(__isl_keep MULTI(BASE) *multi)
        hash = isl_hash_init();
        for (i = 0; i < multi->n; ++i) {
                uint32_t el_hash;
-               el_hash = FN(EL,get_hash)(multi->p[i]);
+               el_hash = FN(EL,get_hash)(multi->u.p[i]);
                isl_hash_hash(hash, el_hash);
        }
 
index d785030..d202903 100644 (file)
@@ -85,7 +85,7 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),dup)(__isl_keep MULTI(BASE) *multi)
 
        for (i = 0; i < multi->n; ++i)
                dup = FN(FN(MULTI(BASE),set),BASE)(dup, i,
-                                                   FN(EL,copy)(multi->p[i]));
+                                                   FN(EL,copy)(multi->u.p[i]));
 
        return dup;
 }
@@ -123,7 +123,7 @@ __isl_null MULTI(BASE) *FN(MULTI(BASE),free)(__isl_take MULTI(BASE) *multi)
 
        isl_space_free(multi->space);
        for (i = 0; i < multi->n; ++i)
-               FN(EL,free)(multi->p[i]);
+               FN(EL,free)(multi->u.p[i]);
        free(multi);
 
        return NULL;
@@ -171,8 +171,9 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),set_dim_name)(
        if (type == isl_dim_out)
                return multi;
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,set_dim_name)(multi->p[i], type, pos, s);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,set_dim_name)(multi->u.p[i],
+                                                       type, pos, s);
+               if (!multi->u.p[i])
                        return FN(MULTI(BASE),free)(multi);
        }
 
@@ -214,7 +215,7 @@ __isl_give EL *FN(FN(MULTI(BASE),get),BASE)(__isl_keep MULTI(BASE) *multi,
        if (pos < 0 || pos >= multi->n)
                isl_die(ctx, isl_error_invalid,
                        "index out of bounds", return NULL);
-       return FN(EL,copy)(multi->p[pos]);
+       return FN(EL,copy)(multi->u.p[pos]);
 }
 
 __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),set),BASE)(
@@ -246,8 +247,8 @@ __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),set),BASE)(
                isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
                        "index out of bounds", goto error);
 
-       FN(EL,free)(multi->p[pos]);
-       multi->p[pos] = el;
+       FN(EL,free)(multi->u.p[pos]);
+       multi->u.p[pos] = el;
 
        isl_space_free(multi_space);
        isl_space_free(el_space);
@@ -278,9 +279,9 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_space_and_domain)(
                goto error;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,reset_domain_space)(multi->p[i],
+               multi->u.p[i] = FN(EL,reset_domain_space)(multi->u.p[i],
                                 isl_space_copy(domain));
-               if (!multi->p[i])
+               if (!multi->u.p[i])
                        goto error;
        }
        isl_space_free(domain);
@@ -417,9 +418,9 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),realign_domain)(
                goto error;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,realign_domain)(multi->p[i],
+               multi->u.p[i] = FN(EL,realign_domain)(multi->u.p[i],
                                                isl_reordering_copy(exp));
-               if (!multi->p[i])
+               if (!multi->u.p[i])
                        goto error;
        }
 
@@ -644,17 +645,17 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),drop_dims)(
 
        if (type == isl_dim_out) {
                for (i = 0; i < n; ++i)
-                       FN(EL,free)(multi->p[first + i]);
+                       FN(EL,free)(multi->u.p[first + i]);
                for (i = first; i + n < multi->n; ++i)
-                       multi->p[i] = multi->p[i + n];
+                       multi->u.p[i] = multi->u.p[i + n];
                multi->n -= n;
 
                return multi;
        }
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,drop_dims)(multi->p[i], type, first, n);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,drop_dims)(multi->u.p[i], type, first, n);
+               if (!multi->u.p[i])
                        return FN(MULTI(BASE),free)(multi);
        }
 
@@ -1040,8 +1041,9 @@ static __isl_give MULTI(BASE) *FN(MULTI(BASE),bin_op)(
                        "spaces don't match", goto error);
 
        for (i = 0; i < multi1->n; ++i) {
-               multi1->p[i] = fn(multi1->p[i], FN(EL,copy)(multi2->p[i]));
-               if (!multi1->p[i])
+               multi1->u.p[i] = fn(multi1->u.p[i],
+                                               FN(EL,copy)(multi2->u.p[i]));
+               if (!multi1->u.p[i])
                        goto error;
        }
 
@@ -1115,8 +1117,9 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_val)(__isl_take MULTI(BASE) *multi,
                return NULL;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,scale_val)(multi->p[i], isl_val_copy(v));
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,scale_val)(multi->u.p[i],
+                                               isl_val_copy(v));
+               if (!multi->u.p[i])
                        goto error;
        }
 
@@ -1154,9 +1157,9 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_down_val)(
                return NULL;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,scale_down_val)(multi->p[i],
+               multi->u.p[i] = FN(EL,scale_down_val)(multi->u.p[i],
                                                    isl_val_copy(v));
-               if (!multi->p[i])
+               if (!multi->u.p[i])
                        goto error;
        }
 
@@ -1191,8 +1194,8 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_multi_val)(
                isl_val *v;
 
                v = isl_multi_val_get_val(mv, i);
-               multi->p[i] = FN(EL,scale_val)(multi->p[i], v);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,scale_val)(multi->u.p[i], v);
+               if (!multi->u.p[i])
                        goto error;
        }
 
@@ -1227,8 +1230,8 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_down_multi_val)(
                isl_val *v;
 
                v = isl_multi_val_get_val(mv, i);
-               multi->p[i] = FN(EL,scale_down_val)(multi->p[i], v);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,scale_down_val)(multi->u.p[i], v);
+               if (!multi->u.p[i])
                        goto error;
        }
 
@@ -1263,8 +1266,8 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),mod_multi_val)(
                isl_val *v;
 
                v = isl_multi_val_get_val(mv, i);
-               multi->p[i] = FN(EL,mod_val)(multi->p[i], v);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,mod_val)(multi->u.p[i], v);
+               if (!multi->u.p[i])
                        goto error;
        }
 
@@ -1322,9 +1325,10 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),move_dims)(__isl_take MULTI(BASE) *multi,
                return FN(MULTI(BASE),free)(multi);
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,move_dims)(multi->p[i], dst_type, dst_pos,
+               multi->u.p[i] = FN(EL,move_dims)(multi->u.p[i],
+                                               dst_type, dst_pos,
                                                src_type, src_pos, n);
-               if (!multi->p[i])
+               if (!multi->u.p[i])
                        return FN(MULTI(BASE),free)(multi);
        }
 
@@ -1371,7 +1375,7 @@ isl_bool FN(MULTI(BASE),plain_is_equal)(__isl_keep MULTI(BASE) *multi1,
                return equal;
 
        for (i = 0; i < multi1->n; ++i) {
-               equal = FN(EL,plain_is_equal)(multi1->p[i], multi2->p[i]);
+               equal = FN(EL,plain_is_equal)(multi1->u.p[i], multi2->u.p[i]);
                if (equal < 0 || !equal)
                        return equal;
        }
@@ -1391,7 +1395,7 @@ isl_bool FN(MULTI(BASE),involves_nan)(__isl_keep MULTI(BASE) *multi)
                return isl_bool_false;
 
        for (i = 0; i < multi->n; ++i) {
-               isl_bool has_nan = FN(EL,involves_nan)(multi->p[i]);
+               isl_bool has_nan = FN(EL,involves_nan)(multi->u.p[i]);
                if (has_nan < 0 || has_nan)
                        return has_nan;
        }
@@ -1435,8 +1439,8 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),neg)(__isl_take MULTI(BASE) *multi)
                return NULL;
 
        for (i = 0; i < multi->n; ++i) {
-               multi->p[i] = FN(EL,neg)(multi->p[i]);
-               if (!multi->p[i])
+               multi->u.p[i] = FN(EL,neg)(multi->u.p[i]);
+               if (!multi->u.p[i])
                        return FN(MULTI(BASE),free)(multi);
        }
 
index 8170892..e528b60 100644 (file)
@@ -2,12 +2,22 @@
 
 #include <isl_multi_macro.h>
 
+/* A multiple expression with base expressions of type EL.
+ *
+ * "space" is the space in which the multiple expression lives.
+ * "n" is the number of base expression and is equal
+ * to the output or set dimension of "space".
+ * "p" is an array of size "n" of base expressions.
+ * The array is only accessible when n > 0.
+ */
 struct MULTI(BASE) {
        int ref;
        isl_space *space;
 
        int n;
-       EL *p[1];
+       struct {
+               EL *p[1];
+       } u;
 };
 
 __isl_give MULTI(BASE) *CAT(MULTI(BASE),_alloc)(__isl_take isl_space *space);
index 4888bae..53cf354 100644 (file)
@@ -2897,7 +2897,7 @@ static __isl_give isl_printer *print_dim_ma(__isl_take isl_printer *p,
        isl_multi_aff *ma = data->user;
 
        if (data->type == isl_dim_out)
-               p = print_aff_body(p, ma->p[pos]);
+               p = print_aff_body(p, ma->u.p[pos]);
        else
                p = print_name(data->space, p, data->type, pos, data->latex);
 
@@ -3003,12 +3003,12 @@ static __isl_give isl_printer *print_unnamed_pw_multi_aff_c(
                p = isl_printer_print_str(p, "(");
                p = print_set_c(p, space, pma->p[i].set);
                p = isl_printer_print_str(p, ") ? (");
-               p = print_aff_c(p, pma->p[i].maff->p[0]);
+               p = print_aff_c(p, pma->p[i].maff->u.p[0]);
                p = isl_printer_print_str(p, ") : ");
        }
        isl_space_free(space);
 
-       return print_aff_c(p, pma->p[pma->n - 1].maff->p[0]);
+       return print_aff_c(p, pma->p[pma->n - 1].maff->u.p[0]);
 }
 
 static __isl_give isl_printer *print_pw_multi_aff_c(__isl_take isl_printer *p,
@@ -3130,7 +3130,7 @@ static __isl_give isl_printer *print_dim_mpa(__isl_take isl_printer *p,
        if (data->type != isl_dim_out)
                return print_name(data->space, p, data->type, pos, data->latex);
 
-       pa = mpa->p[pos];
+       pa = mpa->u.p[pos];
        if (pa->n == 0)
                return isl_printer_print_str(p, "(0 : false)");
 
@@ -3197,7 +3197,7 @@ static __isl_give isl_printer *print_dim_mv(__isl_take isl_printer *p,
        isl_multi_val *mv = data->user;
 
        if (data->type == isl_dim_out)
-               return isl_printer_print_val(p, mv->p[pos]);
+               return isl_printer_print_val(p, mv->u.p[pos]);
        else
                return print_name(data->space, p, data->type, pos, data->latex);
 }
index c501034..e305cfd 100644 (file)
@@ -5765,7 +5765,7 @@ static int need_substitution(__isl_keep isl_multi_aff *maff)
        pos = isl_multi_aff_dim(maff, isl_dim_in) - 1;
 
        for (i = 0; i < maff->n; ++i)
-               if (isl_aff_involves_dims(maff->p[i], isl_dim_in, pos, 1))
+               if (isl_aff_involves_dims(maff->u.p[i], isl_dim_in, pos, 1))
                        return 1;
 
        return 0;
index e6d4cba..a8be9ac 100644 (file)
--- a/isl_val.c
+++ b/isl_val.c
@@ -1658,8 +1658,8 @@ static __isl_give isl_multi_val *isl_multi_val_fn_val(
                goto error;
 
        for (i = 0; i < mv->n; ++i) {
-               mv->p[i] = fn(mv->p[i], isl_val_copy(v));
-               if (!mv->p[i])
+               mv->u.p[i] = fn(mv->u.p[i], isl_val_copy(v));
+               if (!mv->u.p[i])
                        goto error;
        }