From: Julian Brown Date: Tue, 5 Feb 2019 15:33:25 +0000 (-0800) Subject: [3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a56d5cfffdb1e74989f86363c043f29ce9228486;p=thirdparty%2Fgcc.git [3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify patch 2018-10-16 Chung-Lin Tang gcc/ * gimplify.c (gimplify_scan_omp_clauses): For dynamic array map kinds, make sure bias in each dimension are put into firstprivate variables. (cherry picked from openacc-gcc-9-branch commit a9cde8c122c4dc48bd8aad71e0c543e07b08a4ca) --- diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index f8f5587779ae..d940ae222e50 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,8 @@ +2018-10-16 Chung-Lin Tang + + * gimplify.c (gimplify_scan_omp_clauses): For dynamic array map kinds, + make sure bias in each dimension are put into firstprivate variables. + 2019-01-31 Julian Brown * gimplify.c (gimplify_scan_omp_clauses): Handle array sections on diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 79d0535c50a8..dc4531bc2d30 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8617,8 +8617,28 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, if (OMP_CLAUSE_SIZE (c) == NULL_TREE) OMP_CLAUSE_SIZE (c) = DECL_P (decl) ? DECL_SIZE_UNIT (decl) : TYPE_SIZE_UNIT (TREE_TYPE (decl)); - if (gimplify_expr (&OMP_CLAUSE_SIZE (c), pre_p, - NULL, is_gimple_val, fb_rvalue) == GS_ERROR) + if (OMP_CLAUSE_SIZE (c) + && TREE_CODE (OMP_CLAUSE_SIZE (c)) == TREE_LIST + && GOMP_MAP_DYNAMIC_ARRAY_P (OMP_CLAUSE_MAP_KIND (c))) + { + tree dims = OMP_CLAUSE_SIZE (c); + for (tree t = dims; t; t = TREE_CHAIN (t)) + { + /* If a dimension bias isn't a constant, we have to ensure + that the value gets transferred to the offload target. */ + tree low_bound = TREE_PURPOSE (t); + if (TREE_CODE (low_bound) != INTEGER_CST) + { + low_bound = get_initialized_tmp_var (low_bound, pre_p, + NULL, false); + omp_add_variable (ctx, low_bound, + GOVD_FIRSTPRIVATE | GOVD_SEEN); + TREE_PURPOSE (t) = low_bound; + } + } + } + else if (gimplify_expr (&OMP_CLAUSE_SIZE (c), pre_p, + NULL, is_gimple_val, fb_rvalue) == GS_ERROR) { remove = true; break;