From bdb7916ce78cef5d52bfdc148576f1999b774fc8 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 20 Feb 2014 10:47:45 +0100 Subject: [PATCH] pet_context: no longer keep track of "unknown" values The only reason we kept track of "unknown" values in the pet_context was to be able to distinguish variable that have had some value assigned to them and those that have never been assigned a value. This information was used inside pet_expr_extract_affine to decide whether we should consider the variable as a parameter. Now that this logic has been removed from pet_expr_extract_affine, there is no longer any need to keep track of unknown values. Signed-off-by: Sven Verdoolaege --- context.c | 34 ++++------------------------------ context.h | 2 -- expr.c | 15 +++------------ tree2scop.c | 12 ++++++------ 4 files changed, 13 insertions(+), 50 deletions(-) diff --git a/context.c b/context.c index 1c90ca4..33680f1 100644 --- a/context.c +++ b/context.c @@ -49,10 +49,6 @@ * Internally, the domains of the values may be equal to some prefix * of the space of "domain", but the domains are updated to be * equal to the space of "domain" before passing them to the user. - * If a variable has been assigned an unknown value (possibly because - * it may be assigned a different expression in each iteration) or a value - * that is not an affine expression, then the corresponding isl_pw_aff - * is set to NaN. * * If "allow_nested" is set, then the affine expression created * in this context may involve new parameters that encode a pet_expr. @@ -307,28 +303,6 @@ error: return NULL; } -/* Return a piecewise affine expression defined on the specified domain - * that represents NaN. - */ -static __isl_give isl_pw_aff *nan_on_domain(__isl_take isl_space *space) -{ - return isl_pw_aff_nan_on_domain(isl_local_space_from_space(space)); -} - -/* Assign the value NaN to "id" in "pc", marked it as having an unknown - * value. - */ -__isl_give pet_context *pet_context_mark_unknown(__isl_take pet_context *pc, - __isl_take isl_id *id) -{ - isl_pw_aff *pa; - - pa = nan_on_domain(pet_context_get_space(pc)); - pc = pet_context_set_value(pc, id, pa); - - return pc; -} - /* Are affine expressions created in this context allowed to involve * parameters that encode a pet_expr? */ @@ -357,7 +331,7 @@ __isl_give pet_context *pet_context_set_allow_nested(__isl_take pet_context *pc, } /* If the access expression "expr" writes to a (non-virtual) scalar, - * then mark the scalar as having an unknown value in "pc". + * then remove any assignment to the scalar in "pc". */ static int clear_write(__isl_keep pet_expr *expr, void *user) { @@ -371,7 +345,7 @@ static int clear_write(__isl_keep pet_expr *expr, void *user) id = pet_expr_access_get_id(expr); if (isl_id_get_user(id)) - *pc = pet_context_mark_unknown(*pc, id); + *pc = pet_context_clear_value(*pc, id); else isl_id_free(id); @@ -379,7 +353,7 @@ static int clear_write(__isl_keep pet_expr *expr, void *user) } /* Look for any writes to scalar variables in "expr" and - * mark them as having an unknown value in "pc". + * remove any assignment to them in "pc". */ __isl_give pet_context *pet_context_clear_writes_in_expr( __isl_take pet_context *pc, __isl_keep pet_expr *expr) @@ -391,7 +365,7 @@ __isl_give pet_context *pet_context_clear_writes_in_expr( } /* Look for any writes to scalar variables in "tree" and - * mark them as having an unknown value in "pc". + * remove any assignment to them in "pc". */ __isl_give pet_context *pet_context_clear_writes_in_tree( __isl_take pet_context *pc, __isl_keep pet_tree *tree) diff --git a/context.h b/context.h index 4693d09..3590f7b 100644 --- a/context.h +++ b/context.h @@ -31,8 +31,6 @@ __isl_give pet_context *pet_context_set_value(__isl_take pet_context *pc, __isl_take isl_id *id, isl_pw_aff *value); __isl_give isl_pw_aff *pet_context_get_value(__isl_keep pet_context *pc, __isl_take isl_id *id); -__isl_give pet_context *pet_context_mark_unknown(__isl_take pet_context *pc, - __isl_take isl_id *id); __isl_give pet_context *pet_context_clear_value(__isl_keep pet_context *pc, __isl_take isl_id *id); __isl_give pet_context *pet_context_set_allow_nested(__isl_take pet_context *pc, diff --git a/expr.c b/expr.c index 3df3e44..aa97172 100644 --- a/expr.c +++ b/expr.c @@ -2096,20 +2096,11 @@ static __isl_give isl_pw_aff *extract_affine_from_access( return nested_access(expr, pc); id = pet_expr_access_get_id(expr); - if (pet_context_is_assigned(pc, id)) { - isl_pw_aff *pa; - - pa = pet_context_get_value(pc, id); - if (!pa) - return NULL; - if (!isl_pw_aff_involves_nan(pa)) - return pa; - isl_pw_aff_free(pa); - return nested_access(expr, pc); - } + if (pet_context_is_assigned(pc, id)) + return pet_context_get_value(pc, id); isl_id_free(id); - return NULL; + return nested_access(expr, pc); } /* Construct an affine expression from the integer constant "expr". diff --git a/tree2scop.c b/tree2scop.c index 067cea7..089ff6a 100644 --- a/tree2scop.c +++ b/tree2scop.c @@ -44,8 +44,8 @@ #include "tree2scop.h" /* Update "pc" by taking into account the writes in "stmt". - * That is, mark all scalar variables that are written by "stmt" - * as having an unknown value. + * That is, clear any previously assigned values to variables + * that are written by "stmt". */ static __isl_give pet_context *handle_writes(struct pet_stmt *stmt, __isl_take pet_context *pc) @@ -975,7 +975,7 @@ static struct pet_scop *scop_from_non_affine_for(__isl_keep pet_tree *tree, struct pet_scop *scop_kill; iv = pet_expr_access_get_id(tree->u.l.iv); - pc = pet_context_mark_unknown(pc, iv); + pc = pet_context_clear_value(pc, iv); declared = tree->u.l.declared; @@ -1372,7 +1372,7 @@ static struct pet_scop *scop_from_for(__isl_keep pet_tree *tree, pc = pet_context_clear_writes_in_tree(pc, tree->u.l.body); pc_init_val = pet_context_copy(pc); - pc_init_val = pet_context_mark_unknown(pc_init_val, isl_id_copy(iv)); + pc_init_val = pet_context_clear_value(pc_init_val, isl_id_copy(iv)); init_val = pet_expr_extract_affine(tree->u.l.init, pc_init_val); pet_context_free(pc_init_val); pa_inc = pet_expr_extract_affine(tree->u.l.inc, pc); @@ -1857,8 +1857,8 @@ static int is_assignment(__isl_keep pet_tree *tree) * if the rhs is an affine expression, then keep track of this value in "pc" * so that we can plug it in when we later come across the same variable. * - * The variable has already been marked as having been assigned - * an unknown value by scop_handle_writes. + * Any previously assigned value to the variable has already been removed + * by scop_handle_writes. */ static __isl_give pet_context *handle_assignment(__isl_take pet_context *pc, __isl_keep pet_tree *tree) -- 2.11.4.GIT