From b604caecc7c926d05521dc9d3fc020de331e7d70 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 6 Dec 2014 09:45:32 +0100 Subject: [PATCH] gpu_array_info: keep track of whether the array is accessed at all This will allows us to easily introduce special treatment for arrays that are not accessed at all. Signed-off-by: Sven Verdoolaege --- gpu.c | 7 ++++++- gpu.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gpu.c b/gpu.c index 1f143cb..e6c3dff 100644 --- a/gpu.c +++ b/gpu.c @@ -406,10 +406,11 @@ static int is_read_only_scalar(struct gpu_array_info *array, * * If the array is zero-dimensional and does not contain structures, * i.e., if the array is a scalar, we check whether it is read-only. + * We also check whether the array is accessed at all. */ static int extract_array_info(__isl_take isl_set *array, void *user) { - int i; + int i, empty; struct gpu_prog *prog = (struct gpu_prog *)user; const char *name; int n_index; @@ -445,8 +446,12 @@ static int extract_array_info(__isl_take isl_set *array, void *user) info->has_compound_element = pa->element_is_record; info->read_only_scalar = is_read_only_scalar(info, prog); + empty = isl_set_is_empty(array); extent = compute_extent(pa, array); info->extent = extent; + if (empty < 0) + return -1; + info->accessed = !empty; for (i = 0; i < n_index; ++i) { isl_set *dom; isl_local_space *ls; diff --git a/gpu.h b/gpu.h index 8f54faf..4ac0940 100644 --- a/gpu.h +++ b/gpu.h @@ -35,6 +35,9 @@ struct gpu_array_info { int n_group; struct gpu_array_ref_group **groups; + /* Is this array accessed at all by the program? */ + int accessed; + /* Is this a scalar that is read-only within the entire program? */ int read_only_scalar; -- 2.11.4.GIT