diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-05-24 23:31:59 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-05-24 23:31:59 +0200 |
commit | 6c7ae8c56f9341f180e097d5eb7ba05cb8eec413 (patch) | |
tree | 425965042d935027e8cc7045b383f6b7b6f714f9 /gcc/gimplify.c | |
parent | 09b4000c7c5b359ec62b5d621daf6ab95233ce10 (diff) | |
download | gcc-6c7ae8c56f9341f180e097d5eb7ba05cb8eec413.zip gcc-6c7ae8c56f9341f180e097d5eb7ba05cb8eec413.tar.gz gcc-6c7ae8c56f9341f180e097d5eb7ba05cb8eec413.tar.bz2 |
tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.
* tree.h (OMP_CLAUSE_DECL): Use OMP_CLAUSE__CONDTEMP_ instead of
OMP_CLAUSE__REDUCTEMP_.
* tree.c (omp_clause_num_ops, omp_clause_code_name): Add
OMP_CLAUSE__CONDTEMP_.
(walk_tree_1): Handle OMP_CLAUSE__CONDTEMP_.
* tree-pretty-print.c (dump_omp_clause): Likewise.
* tree-nested.c (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Likewise.
* gimplify.c (enum gimplify_omp_var_data): Use hexadecimal constants
instead of decimal. Add GOVD_LASTPRIVATE_CONDITIONAL.
(gimplify_scan_omp_clauses): Don't reject lastprivate conditional
on OMP_FOR.
(gimplify_omp_for): Warn and disable conditional modifier from
lastprivate on loop iterators.
* omp-general.h (struct omp_for_data): Add lastprivate_conditional
member.
* omp-general.c (omp_extract_for_data): Initialize it.
* omp-low.c (struct omp_context): Add lastprivate_conditional_map
member.
(delete_omp_context): Delete it.
(lower_lastprivate_conditional_clauses): New function.
(lower_lastprivate_clauses): Add BODY_P and CSTMT_LIST arguments,
handle lastprivate conditional clauses.
(lower_reduction_clauses): Add CLIST argument, emit it into
the critical section if any.
(lower_omp_sections): Adjust lower_lastprivate_clauses and
lower_reduction_clauses callers.
(lower_omp_for_lastprivate): Add CLIST argument, pass it through
to lower_lastprivate_clauses.
(lower_omp_for): Call lower_lastprivate_conditional_clauses, adjust
lower_omp_for_lastprivate and lower_reduction_clauses callers, emit
clist into a critical section if not emitted there already by
lower_reduction_clauses.
(lower_omp_taskreg, lower_omp_teams): Adjust lower_reduction_clauses
callers.
(lower_omp_1): Handle GIMPLE_ASSIGNs storing into lastprivate
conditional variables.
* omp-expand.c (determine_parallel_type): Punt if OMP_CLAUSE__CONDTEMP_
clause is present.
(expand_omp_for_generic, expand_omp_for_static_nochunk,
expand_omp_for_static_chunk): Handle lastprivate conditional.
(expand_omp_for): Handle fd.lastprivate_conditional like
fd.have_reductemp.
gcc/testsuite/
* c-c++-common/gomp/lastprivate-conditional-2.c (foo): Don't expect
sorry for omp for.
* c-c++-common/gomp/lastprivate-conditional-3.c: New test.
libgomp/
* testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c: New test.
* testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c: New test.
From-SVN: r271610
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 99 |
1 files changed, 71 insertions, 28 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index e5713dd..b8b7e80 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -71,47 +71,50 @@ static hash_set<tree> *asan_poisoned_variables = NULL; enum gimplify_omp_var_data { - GOVD_SEEN = 1, - GOVD_EXPLICIT = 2, - GOVD_SHARED = 4, - GOVD_PRIVATE = 8, - GOVD_FIRSTPRIVATE = 16, - GOVD_LASTPRIVATE = 32, - GOVD_REDUCTION = 64, - GOVD_LOCAL = 128, - GOVD_MAP = 256, - GOVD_DEBUG_PRIVATE = 512, - GOVD_PRIVATE_OUTER_REF = 1024, - GOVD_LINEAR = 2048, - GOVD_ALIGNED = 4096, + GOVD_SEEN = 0x000001, + GOVD_EXPLICIT = 0x000002, + GOVD_SHARED = 0x000004, + GOVD_PRIVATE = 0x000008, + GOVD_FIRSTPRIVATE = 0x000010, + GOVD_LASTPRIVATE = 0x000020, + GOVD_REDUCTION = 0x000040, + GOVD_LOCAL = 0x00080, + GOVD_MAP = 0x000100, + GOVD_DEBUG_PRIVATE = 0x000200, + GOVD_PRIVATE_OUTER_REF = 0x000400, + GOVD_LINEAR = 0x000800, + GOVD_ALIGNED = 0x001000, /* Flag for GOVD_MAP: don't copy back. */ - GOVD_MAP_TO_ONLY = 8192, + GOVD_MAP_TO_ONLY = 0x002000, /* Flag for GOVD_LINEAR or GOVD_LASTPRIVATE: no outer reference. */ - GOVD_LINEAR_LASTPRIVATE_NO_OUTER = 16384, + GOVD_LINEAR_LASTPRIVATE_NO_OUTER = 0x004000, - GOVD_MAP_0LEN_ARRAY = 32768, + GOVD_MAP_0LEN_ARRAY = 0x008000, /* Flag for GOVD_MAP, if it is always, to or always, tofrom mapping. */ - GOVD_MAP_ALWAYS_TO = 65536, + GOVD_MAP_ALWAYS_TO = 0x010000, /* Flag for shared vars that are or might be stored to in the region. */ - GOVD_WRITTEN = 131072, + GOVD_WRITTEN = 0x020000, /* Flag for GOVD_MAP, if it is a forced mapping. */ - GOVD_MAP_FORCE = 262144, + GOVD_MAP_FORCE = 0x040000, /* Flag for GOVD_MAP: must be present already. */ - GOVD_MAP_FORCE_PRESENT = 524288, + GOVD_MAP_FORCE_PRESENT = 0x080000, /* Flag for GOVD_MAP: only allocate. */ - GOVD_MAP_ALLOC_ONLY = 1048576, + GOVD_MAP_ALLOC_ONLY = 0x100000, /* Flag for GOVD_MAP: only copy back. */ - GOVD_MAP_FROM_ONLY = 2097152, + GOVD_MAP_FROM_ONLY = 0x200000, - GOVD_NONTEMPORAL = 4194304, + GOVD_NONTEMPORAL = 0x400000, + + /* Flag for GOVD_LASTPRIVATE: conditional modifier. */ + GOVD_LASTPRIVATE_CONDITIONAL = 0x800000, GOVD_DATA_SHARE_CLASS = (GOVD_SHARED | GOVD_PRIVATE | GOVD_FIRSTPRIVATE | GOVD_LASTPRIVATE | GOVD_REDUCTION | GOVD_LINEAR @@ -8139,9 +8142,17 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 0; } if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c)) - sorry_at (OMP_CLAUSE_LOCATION (c), - "%<conditional%> modifier on %<lastprivate%> clause " - "not supported yet"); + { + if (code == OMP_FOR) + flags |= GOVD_LASTPRIVATE_CONDITIONAL; + else + { + sorry_at (OMP_CLAUSE_LOCATION (c), + "%<conditional%> modifier on %<lastprivate%> " + "clause not supported yet"); + OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 0; + } + } if (outer_ctx && (outer_ctx->region_type == ORT_COMBINED_PARALLEL || ((outer_ctx->region_type & ORT_COMBINED_TEAMS) @@ -10770,7 +10781,22 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) 1 + (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) != 1)); if (n != NULL && (n->value & GOVD_DATA_SHARE_CLASS) != 0) - omp_notice_variable (gimplify_omp_ctxp, decl, true); + { + omp_notice_variable (gimplify_omp_ctxp, decl, true); + if (n->value & GOVD_LASTPRIVATE_CONDITIONAL) + for (tree c3 = omp_find_clause (OMP_FOR_CLAUSES (for_stmt), + OMP_CLAUSE_LASTPRIVATE); + c3; c3 = omp_find_clause (OMP_CLAUSE_CHAIN (c3), + OMP_CLAUSE_LASTPRIVATE)) + if (OMP_CLAUSE_DECL (c3) == decl) + { + warning_at (OMP_CLAUSE_LOCATION (c3), 0, + "conditional %<lastprivate%> on loop " + "iterator %qD ignored", decl); + OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c3) = 0; + n->value &= ~GOVD_LASTPRIVATE_CONDITIONAL; + } + } else if (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) == 1) { c = build_omp_clause (input_location, OMP_CLAUSE_LINEAR); @@ -11005,7 +11031,24 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) } } else if (omp_is_private (gimplify_omp_ctxp, decl, 0)) - omp_notice_variable (gimplify_omp_ctxp, decl, true); + { + omp_notice_variable (gimplify_omp_ctxp, decl, true); + splay_tree_node n = splay_tree_lookup (gimplify_omp_ctxp->variables, + (splay_tree_key) decl); + if (n && (n->value & GOVD_LASTPRIVATE_CONDITIONAL)) + for (tree c3 = omp_find_clause (OMP_FOR_CLAUSES (for_stmt), + OMP_CLAUSE_LASTPRIVATE); + c3; c3 = omp_find_clause (OMP_CLAUSE_CHAIN (c3), + OMP_CLAUSE_LASTPRIVATE)) + if (OMP_CLAUSE_DECL (c3) == decl) + { + warning_at (OMP_CLAUSE_LOCATION (c3), 0, + "conditional %<lastprivate%> on loop " + "iterator %qD ignored", decl); + OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c3) = 0; + n->value &= ~GOVD_LASTPRIVATE_CONDITIONAL; + } + } else omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN); |