From 86637b4edf950cd88d87037cb6f156d0c7491423 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 9 Mar 2014 15:19:52 +0100 Subject: [PATCH] drop pet_scop_detect_parameter_accesses In the previous commit, we changed pet_context_evaluate_expr to plug in affine expressions for scalar reads. This means in particular that pet_context_evaluate_expr will plug in parameters for reads to accesses to the corresponding variable. There is therefore no longer any need for pet_scop_detect_parameter_accesses to look for such reads at the end of the scop construction as they will already have been handled by pet_context_evaluate_expr during the scop construction. Signed-off-by: Sven Verdoolaege --- expr.c | 114 ---------------------------------------------------------------- expr.h | 2 -- scan.cc | 1 - scop.c | 66 ------------------------------------- scop.h | 2 -- 5 files changed, 185 deletions(-) diff --git a/expr.c b/expr.c index dca868f..60fdc59 100644 --- a/expr.c +++ b/expr.c @@ -1449,120 +1449,6 @@ error: return pet_expr_free(expr); } -/* Check if the given index expression accesses a (0D) array that corresponds - * to one of the parameters in "space". If so, replace the array access - * by an access to the set of integers with as index (and value) - * that parameter. - */ -static __isl_give isl_multi_pw_aff *index_detect_parameter( - __isl_take isl_multi_pw_aff *index, __isl_take isl_space *space) -{ - isl_local_space *ls; - isl_id *array_id = NULL; - isl_aff *aff; - int pos = -1; - - if (isl_multi_pw_aff_has_tuple_id(index, isl_dim_out)) { - array_id = isl_multi_pw_aff_get_tuple_id(index, isl_dim_out); - pos = isl_space_find_dim_by_id(space, isl_dim_param, array_id); - } - isl_space_free(space); - - if (pos < 0) { - isl_id_free(array_id); - return index; - } - - space = isl_multi_pw_aff_get_domain_space(index); - isl_multi_pw_aff_free(index); - - pos = isl_space_find_dim_by_id(space, isl_dim_param, array_id); - if (pos < 0) { - space = isl_space_insert_dims(space, isl_dim_param, 0, 1); - space = isl_space_set_dim_id(space, isl_dim_param, 0, array_id); - pos = 0; - } else - isl_id_free(array_id); - - ls = isl_local_space_from_space(space); - aff = isl_aff_var_on_domain(ls, isl_dim_param, pos); - index = isl_multi_pw_aff_from_pw_aff(isl_pw_aff_from_aff(aff)); - - return index; -} - -/* Check if the given access relation accesses a (0D) array that corresponds - * to one of the parameters in "space". If so, replace the array access - * by an access to the set of integers with as index (and value) - * that parameter. - */ -static __isl_give isl_map *access_detect_parameter(__isl_take isl_map *access, - __isl_take isl_space *space) -{ - isl_id *array_id = NULL; - int pos = -1; - - if (isl_map_has_tuple_id(access, isl_dim_out)) { - array_id = isl_map_get_tuple_id(access, isl_dim_out); - pos = isl_space_find_dim_by_id(space, isl_dim_param, array_id); - } - isl_space_free(space); - - if (pos < 0) { - isl_id_free(array_id); - return access; - } - - pos = isl_map_find_dim_by_id(access, isl_dim_param, array_id); - if (pos < 0) { - access = isl_map_insert_dims(access, isl_dim_param, 0, 1); - access = isl_map_set_dim_id(access, isl_dim_param, 0, array_id); - pos = 0; - } else - isl_id_free(array_id); - - access = isl_map_insert_dims(access, isl_dim_out, 0, 1); - access = isl_map_equate(access, isl_dim_param, pos, isl_dim_out, 0); - - return access; -} - -/* If "expr" accesses a (0D) array that corresponds to one of the parameters - * in "space" then replace it by a value equal to the corresponding parameter. - */ -static __isl_give pet_expr *detect_parameter_accesses(__isl_take pet_expr *expr, - void *user) -{ - isl_space *space = user; - - expr = pet_expr_cow(expr); - if (!expr) - return NULL; - if (expr->type != pet_expr_access) - isl_die(pet_expr_get_ctx(expr), isl_error_invalid, - "not an access expression", return pet_expr_free(expr)); - - expr->acc.access = access_detect_parameter(expr->acc.access, - isl_space_copy(space)); - expr->acc.index = index_detect_parameter(expr->acc.index, - isl_space_copy(space)); - if (!expr->acc.access || !expr->acc.index) - return pet_expr_free(expr); - - return expr; -} - -/* Replace all accesses to (0D) arrays that correspond to one of the parameters - * in "space" by a value equal to the corresponding parameter. - */ -__isl_give pet_expr *pet_expr_detect_parameter_accesses( - __isl_take pet_expr *expr, __isl_take isl_space *space) -{ - expr = pet_expr_map_access(expr, &detect_parameter_accesses, space); - isl_space_free(space); - return expr; -} - /* Add a reference identifier to access expression "expr". * "user" points to an integer that contains the sequence number * of the next reference. diff --git a/expr.h b/expr.h index 8008c08..4e67f42 100644 --- a/expr.h +++ b/expr.h @@ -165,8 +165,6 @@ __isl_give pet_expr *pet_expr_align_params(__isl_take pet_expr *expr, __isl_take isl_space *space); __isl_give pet_expr *pet_expr_filter(__isl_take pet_expr *expr, __isl_take isl_multi_pw_aff *test, int satisfied); -__isl_give pet_expr *pet_expr_detect_parameter_accesses( - __isl_take pet_expr *expr, __isl_take isl_space *space); __isl_give pet_expr *pet_expr_add_ref_ids(__isl_take pet_expr *expr, int *n_ref); __isl_give pet_expr *pet_expr_anonymize(__isl_take pet_expr *expr); diff --git a/scan.cc b/scan.cc index c601812..356c765 100644 --- a/scan.cc +++ b/scan.cc @@ -1592,7 +1592,6 @@ struct pet_scop *PetScan::extract_scop(__isl_take pet_tree *tree) pc = pet_context_clear_writes_in_tree(pc, tree); scop = pet_scop_from_pet_tree(tree, int_size, &::extract_array, this, pc); - scop = pet_scop_detect_parameter_accesses(scop); scop = scan_arrays(scop, pc); pet_context_free(pc); diff --git a/scop.c b/scop.c index d622e7a..bde44ac 100644 --- a/scop.c +++ b/scop.c @@ -2558,72 +2558,6 @@ struct pet_scop *pet_scop_align_params(struct pet_scop *scop) return scop; } -/* Replace all accesses to (0D) arrays that correspond to one of the parameters - * in "space" by a value equal to the corresponding parameter. - */ -static struct pet_stmt *stmt_detect_parameter_accesses(struct pet_stmt *stmt, - __isl_take isl_space *space) -{ - if (!stmt) - goto error; - - stmt->body = pet_expr_detect_parameter_accesses(stmt->body, - isl_space_copy(space)); - - if (!stmt->domain || !stmt->schedule || !stmt->body) - goto error; - - isl_space_free(space); - return stmt; -error: - isl_space_free(space); - return pet_stmt_free(stmt); -} - -/* Replace all accesses to (0D) arrays that correspond to one of the parameters - * in "space" by a value equal to the corresponding parameter. - */ -static struct pet_scop *scop_detect_parameter_accesses(struct pet_scop *scop, - __isl_take isl_space *space) -{ - int i; - - if (!scop) - goto error; - - for (i = 0; i < scop->n_stmt; ++i) { - scop->stmts[i] = stmt_detect_parameter_accesses(scop->stmts[i], - isl_space_copy(space)); - if (!scop->stmts[i]) - goto error; - } - - isl_space_free(space); - return scop; -error: - isl_space_free(space); - return pet_scop_free(scop); -} - -/* Replace all accesses to (0D) arrays that correspond to any of - * the parameters used in "scop" by a value equal - * to the corresponding parameter. - */ -struct pet_scop *pet_scop_detect_parameter_accesses(struct pet_scop *scop) -{ - isl_space *space; - - if (!scop) - return NULL; - - space = isl_set_get_space(scop->context); - space = scop_collect_params(scop, space); - - scop = scop_detect_parameter_accesses(scop, space); - - return scop; -} - /* Add the access relation of the access expression "expr" to "accesses" and * return the result. * The domain of the access relation is intersected with "domain". diff --git a/scop.h b/scop.h index 55eb5bc..c354e65 100644 --- a/scop.h +++ b/scop.h @@ -62,8 +62,6 @@ struct pet_scop *pet_scop_merge_filters(struct pet_scop *scop); struct pet_scop *pet_scop_add_implication(struct pet_scop *scop, __isl_take isl_map *map, int satisfied); -struct pet_scop *pet_scop_detect_parameter_accesses(struct pet_scop *scop); - struct pet_scop *pet_scop_gist(struct pet_scop *scop, __isl_keep isl_union_map *value_bounds); -- 2.11.4.GIT