diff options
author | Alexander Monakov <amonakov@ispras.ru> | 2017-04-20 20:21:50 +0300 |
---|---|---|
committer | Alexander Monakov <amonakov@gcc.gnu.org> | 2017-04-20 20:21:50 +0300 |
commit | 2260d19d4be6218c0dfffe6f87fc7665a09d5ba5 (patch) | |
tree | d48f636ed59fd051513d237e7f224ac325b3b196 /gcc/omp-low.c | |
parent | c3cbcd451736f5257446e927bb880ace569f4a45 (diff) | |
download | gcc-2260d19d4be6218c0dfffe6f87fc7665a09d5ba5.tar.gz |
omp-low: fix lastprivate/linear lowering for SIMT
gcc/
* omp-low.c (lower_lastprivate_clauses): Correct handling of linear and
lastprivate clauses in SIMT case.
libgomp/
* testsuite/libgomp.c/target-36.c: New testcase.
From-SVN: r247029
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r-- | gcc/omp-low.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 22772ba2891..9cc29964dfa 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -4770,11 +4770,10 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list, TREE_NO_WARNING (new_var) = 1; } - if (simduid && DECL_HAS_VALUE_EXPR_P (new_var)) + if (!maybe_simt && simduid && DECL_HAS_VALUE_EXPR_P (new_var)) { tree val = DECL_VALUE_EXPR (new_var); - if (!maybe_simt - && TREE_CODE (val) == ARRAY_REF + if (TREE_CODE (val) == ARRAY_REF && VAR_P (TREE_OPERAND (val, 0)) && lookup_attribute ("omp simd array", DECL_ATTRIBUTES (TREE_OPERAND (val, @@ -4794,26 +4793,26 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list, TREE_OPERAND (val, 0), lastlane, NULL_TREE, NULL_TREE); } - else if (maybe_simt - && VAR_P (val) - && lookup_attribute ("omp simt private", - DECL_ATTRIBUTES (val))) + } + else if (maybe_simt) + { + tree val = (DECL_HAS_VALUE_EXPR_P (new_var) + ? DECL_VALUE_EXPR (new_var) + : new_var); + if (simtlast == NULL) { - if (simtlast == NULL) - { - simtlast = create_tmp_var (unsigned_type_node); - gcall *g = gimple_build_call_internal - (IFN_GOMP_SIMT_LAST_LANE, 1, simtcond); - gimple_call_set_lhs (g, simtlast); - gimple_seq_add_stmt (stmt_list, g); - } - x = build_call_expr_internal_loc - (UNKNOWN_LOCATION, IFN_GOMP_SIMT_XCHG_IDX, - TREE_TYPE (val), 2, val, simtlast); - new_var = unshare_expr (new_var); - gimplify_assign (new_var, x, stmt_list); - new_var = unshare_expr (new_var); + simtlast = create_tmp_var (unsigned_type_node); + gcall *g = gimple_build_call_internal + (IFN_GOMP_SIMT_LAST_LANE, 1, simtcond); + gimple_call_set_lhs (g, simtlast); + gimple_seq_add_stmt (stmt_list, g); } + x = build_call_expr_internal_loc + (UNKNOWN_LOCATION, IFN_GOMP_SIMT_XCHG_IDX, + TREE_TYPE (val), 2, val, simtlast); + new_var = unshare_expr (new_var); + gimplify_assign (new_var, x, stmt_list); + new_var = unshare_expr (new_var); } if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE |