aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-05-30 23:19:39 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-05-30 23:19:39 +0200
commit8221c30b09f406fdab07df228e4bad4d3da7b1fe (patch)
tree74b2d1d914fc19d40c61df14f7444e8e4b9c8550 /gcc/gimplify.c
parent00a0e1f5a3bd62519e4742477e11a32c7df2db98 (diff)
downloadgcc-8221c30b09f406fdab07df228e4bad4d3da7b1fe.zip
gcc-8221c30b09f406fdab07df228e4bad4d3da7b1fe.tar.gz
gcc-8221c30b09f406fdab07df228e4bad4d3da7b1fe.tar.bz2
gimplify.c (enum gimplify_omp_var_data): Add GOVD_CONDTEMP.
* gimplify.c (enum gimplify_omp_var_data): Add GOVD_CONDTEMP. (gimplify_adjust_omp_clauses_1): Handle GOVD_CONDTEMP. (gimplify_omp_for): If worksharing loop with lastprivate conditional is nested inside of parallel region, add _condtemp_ clause to both. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Ignore OMP_CLAUSE__CONDTEMP_ instead of assertion failure. * omp-general.h (struct omp_for_data): Add have_pointer_condtemp member. * omp-general.c (omp_extract_for_data): Compute it. * omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE__CONDTEMP_. (lower_rec_input_clauses): Likewise. (lower_lastprivate_conditional_clauses): If OMP_CLAUSE__CONDTEMP_ clause is already present, just add one further one after it. (lower_lastprivate_clauses): Handle cond_ptr with array type. (lower_send_shared_vars): Clear _condtemp_ vars. (lower_omp_1) <case GIMPLE_ASSIGN>: Handle target data like critical or section or taskgroup. * omp-expand.c (determine_parallel_type): Disallow combining only if first OMP_CLAUSE__CONDTEMP_ has pointer type. Disallow combining of parallel sections if OMP_CLAUSE__CONDTEMP_ is present. (expand_omp_for_generic, expand_omp_for_static_nochunk, expand_omp_for_static_chunk, expand_omp_for): Use fd->have_pointer_condtemp instead of fd->lastprivate_conditional to determine if a special set of API routines are needed and if condtemp needs to be initialized, while always initialize cond_var if fd->lastprivate_conditional is non-zero. From-SVN: r271791
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 539cc40..12b1eff 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -116,6 +116,8 @@ enum gimplify_omp_var_data
/* Flag for GOVD_LASTPRIVATE: conditional modifier. */
GOVD_LASTPRIVATE_CONDITIONAL = 0x800000,
+ GOVD_CONDTEMP = 0x1000000,
+
GOVD_DATA_SHARE_CLASS = (GOVD_SHARED | GOVD_PRIVATE | GOVD_FIRSTPRIVATE
| GOVD_LASTPRIVATE | GOVD_REDUCTION | GOVD_LINEAR
| GOVD_LOCAL)
@@ -9527,6 +9529,11 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
code = OMP_CLAUSE_LASTPRIVATE;
else if (flags & (GOVD_ALIGNED | GOVD_NONTEMPORAL))
return 0;
+ else if (flags & GOVD_CONDTEMP)
+ {
+ code = OMP_CLAUSE__CONDTEMP_;
+ gimple_add_tmp_var (decl);
+ }
else
gcc_unreachable ();
@@ -11523,6 +11530,36 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
}
else
gimplify_seq_add_stmt (pre_p, gfor);
+
+ if (TREE_CODE (orig_for_stmt) == OMP_FOR)
+ {
+ struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
+ unsigned lastprivate_conditional = 0;
+ while (ctx
+ && (ctx->region_type == ORT_TARGET_DATA
+ || ctx->region_type == ORT_TASKGROUP))
+ ctx = ctx->outer_context;
+ if (ctx && (ctx->region_type & ORT_PARALLEL) != 0)
+ for (tree c = gimple_omp_for_clauses (gfor);
+ c; c = OMP_CLAUSE_CHAIN (c))
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
+ && OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c))
+ ++lastprivate_conditional;
+ if (lastprivate_conditional)
+ {
+ struct omp_for_data fd;
+ omp_extract_for_data (gfor, &fd, NULL);
+ tree type = build_array_type_nelts (unsigned_type_for (fd.iter_type),
+ lastprivate_conditional);
+ tree var = create_tmp_var_raw (type);
+ tree c = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE__CONDTEMP_);
+ OMP_CLAUSE_DECL (c) = var;
+ OMP_CLAUSE_CHAIN (c) = gimple_omp_for_clauses (gfor);
+ gimple_omp_for_set_clauses (gfor, c);
+ omp_add_variable (ctx, var, GOVD_CONDTEMP | GOVD_SEEN);
+ }
+ }
+
if (ret != GS_ALL_DONE)
return GS_ERROR;
*expr_p = NULL_TREE;