From eba7c15c4128ace1dc4e078b122b98bc62182ecc Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 2 Jul 2015 13:14:26 +0200 Subject: [PATCH] isl_union_templ.c: extract out shared isl_union_*_negate_type Signed-off-by: Sven Verdoolaege --- isl_union_templ.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/isl_union_templ.c b/isl_union_templ.c index f24de090..c1e5ece1 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -943,6 +943,27 @@ error: return NULL; } +#ifdef HAS_TYPE +/* Negate the type of "u". + */ +static __isl_give UNION *FN(UNION,negate_type)(__isl_take UNION *u) +{ + u = FN(UNION,cow)(u); + if (!u) + return NULL; + u->type = isl_fold_type_negate(u->type); + return u; +} +#else +/* Negate the type of "u". + * Since "u" does not have a type, do nothing. + */ +static __isl_give UNION *FN(UNION,negate_type)(__isl_take UNION *u) +{ + return u; +} +#endif + static isl_stat FN(UNION,mul_isl_int_entry)(void **entry, void *user) { PW **pw = (PW **)entry; @@ -973,13 +994,11 @@ __isl_give UNION *FN(UNION,mul_isl_int)(__isl_take UNION *u, isl_int v) } u = FN(UNION,cow)(u); + if (isl_int_is_neg(v)) + u = FN(UNION,negate_type)(u); if (!u) return NULL; -#ifdef HAS_TYPE - if (isl_int_is_neg(v)) - u->type = isl_fold_type_negate(u->type); -#endif if (isl_hash_table_foreach(u->space->ctx, &u->table, &FN(UNION,mul_isl_int_entry), &v) < 0) goto error; @@ -1036,13 +1055,11 @@ __isl_give UNION *FN(UNION,scale_val)(__isl_take UNION *u, "expecting rational factor", goto error); u = FN(UNION,cow)(u); + if (isl_val_is_neg(v)) + u = FN(UNION,negate_type)(u); if (!u) return NULL; -#ifdef HAS_TYPE - if (isl_val_is_neg(v)) - u->type = isl_fold_type_negate(u->type); -#endif if (isl_hash_table_foreach(u->space->ctx, &u->table, &FN(UNION,scale_val_entry), v) < 0) goto error; @@ -1091,13 +1108,11 @@ __isl_give UNION *FN(UNION,scale_down_val)(__isl_take UNION *u, "cannot scale down by zero", goto error); u = FN(UNION,cow)(u); + if (isl_val_is_neg(v)) + u = FN(UNION,negate_type)(u); if (!u) return NULL; -#ifdef HAS_TYPE - if (isl_val_is_neg(v)) - u->type = isl_fold_type_negate(u->type); -#endif if (isl_hash_table_foreach(FN(UNION,get_ctx)(u), &u->table, &FN(UNION,scale_down_val_entry), v) < 0) goto error; -- 2.11.4.GIT