Commit 8221c30b by Jakub Jelinek Committed by Jakub Jelinek

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
parent 00a0e1f5
2019-05-30 Jakub Jelinek <jakub@redhat.com>
* 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.
2019-05-30 Bill Schmidt <wschmidt@linux.ibm.com> 2019-05-30 Bill Schmidt <wschmidt@linux.ibm.com>
Michael Meissner <meissner@linux.ibm.com> Michael Meissner <meissner@linux.ibm.com>
......
...@@ -116,6 +116,8 @@ enum gimplify_omp_var_data ...@@ -116,6 +116,8 @@ enum gimplify_omp_var_data
/* Flag for GOVD_LASTPRIVATE: conditional modifier. */ /* Flag for GOVD_LASTPRIVATE: conditional modifier. */
GOVD_LASTPRIVATE_CONDITIONAL = 0x800000, GOVD_LASTPRIVATE_CONDITIONAL = 0x800000,
GOVD_CONDTEMP = 0x1000000,
GOVD_DATA_SHARE_CLASS = (GOVD_SHARED | GOVD_PRIVATE | GOVD_FIRSTPRIVATE GOVD_DATA_SHARE_CLASS = (GOVD_SHARED | GOVD_PRIVATE | GOVD_FIRSTPRIVATE
| GOVD_LASTPRIVATE | GOVD_REDUCTION | GOVD_LINEAR | GOVD_LASTPRIVATE | GOVD_REDUCTION | GOVD_LINEAR
| GOVD_LOCAL) | GOVD_LOCAL)
...@@ -9527,6 +9529,11 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) ...@@ -9527,6 +9529,11 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
code = OMP_CLAUSE_LASTPRIVATE; code = OMP_CLAUSE_LASTPRIVATE;
else if (flags & (GOVD_ALIGNED | GOVD_NONTEMPORAL)) else if (flags & (GOVD_ALIGNED | GOVD_NONTEMPORAL))
return 0; return 0;
else if (flags & GOVD_CONDTEMP)
{
code = OMP_CLAUSE__CONDTEMP_;
gimple_add_tmp_var (decl);
}
else else
gcc_unreachable (); gcc_unreachable ();
...@@ -11523,6 +11530,36 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) ...@@ -11523,6 +11530,36 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
} }
else else
gimplify_seq_add_stmt (pre_p, gfor); 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) if (ret != GS_ALL_DONE)
return GS_ERROR; return GS_ERROR;
*expr_p = NULL_TREE; *expr_p = NULL_TREE;
......
...@@ -346,12 +346,15 @@ determine_parallel_type (struct omp_region *region) ...@@ -346,12 +346,15 @@ determine_parallel_type (struct omp_region *region)
== OMP_CLAUSE_SCHEDULE_STATIC) == OMP_CLAUSE_SCHEDULE_STATIC)
|| omp_find_clause (clauses, OMP_CLAUSE_ORDERED) || omp_find_clause (clauses, OMP_CLAUSE_ORDERED)
|| omp_find_clause (clauses, OMP_CLAUSE__REDUCTEMP_) || omp_find_clause (clauses, OMP_CLAUSE__REDUCTEMP_)
|| omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_)) || ((c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_))
&& POINTER_TYPE_P (TREE_TYPE (OMP_CLAUSE_DECL (c)))))
return; return;
} }
else if (region->inner->type == GIMPLE_OMP_SECTIONS else if (region->inner->type == GIMPLE_OMP_SECTIONS
&& omp_find_clause (gimple_omp_sections_clauses (ws_stmt), && (omp_find_clause (gimple_omp_sections_clauses (ws_stmt),
OMP_CLAUSE__REDUCTEMP_)) OMP_CLAUSE__REDUCTEMP_)
|| omp_find_clause (gimple_omp_sections_clauses (ws_stmt),
OMP_CLAUSE__CONDTEMP_)))
return; return;
region->is_combined_parallel = true; region->is_combined_parallel = true;
...@@ -2686,6 +2689,15 @@ expand_omp_for_generic (struct omp_region *region, ...@@ -2686,6 +2689,15 @@ expand_omp_for_generic (struct omp_region *region,
tree reductions = NULL_TREE; tree reductions = NULL_TREE;
tree mem = NULL_TREE, cond_var = NULL_TREE, condtemp = NULL_TREE; tree mem = NULL_TREE, cond_var = NULL_TREE, condtemp = NULL_TREE;
tree memv = NULL_TREE; tree memv = NULL_TREE;
if (fd->lastprivate_conditional)
{
tree c = omp_find_clause (gimple_omp_for_clauses (fd->for_stmt),
OMP_CLAUSE__CONDTEMP_);
if (fd->have_pointer_condtemp)
condtemp = OMP_CLAUSE_DECL (c);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_);
cond_var = OMP_CLAUSE_DECL (c);
}
if (sched_arg) if (sched_arg)
{ {
if (fd->have_reductemp) if (fd->have_reductemp)
...@@ -2705,13 +2717,8 @@ expand_omp_for_generic (struct omp_region *region, ...@@ -2705,13 +2717,8 @@ expand_omp_for_generic (struct omp_region *region,
} }
else else
reductions = null_pointer_node; reductions = null_pointer_node;
if (fd->lastprivate_conditional) if (fd->have_pointer_condtemp)
{ {
tree c = omp_find_clause (gimple_omp_for_clauses (fd->for_stmt),
OMP_CLAUSE__CONDTEMP_);
condtemp = OMP_CLAUSE_DECL (c);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_);
cond_var = OMP_CLAUSE_DECL (c);
tree type = TREE_TYPE (condtemp); tree type = TREE_TYPE (condtemp);
memv = create_tmp_var (type); memv = create_tmp_var (type);
TREE_ADDRESSABLE (memv) = 1; TREE_ADDRESSABLE (memv) = 1;
...@@ -2978,7 +2985,7 @@ expand_omp_for_generic (struct omp_region *region, ...@@ -2978,7 +2985,7 @@ expand_omp_for_generic (struct omp_region *region,
gsi_insert_before (&gsi, gimple_build_assign (arr, clobber), gsi_insert_before (&gsi, gimple_build_assign (arr, clobber),
GSI_SAME_STMT); GSI_SAME_STMT);
} }
if (fd->lastprivate_conditional) if (fd->have_pointer_condtemp)
expand_omp_build_assign (&gsi, condtemp, memv, false); expand_omp_build_assign (&gsi, condtemp, memv, false);
if (fd->have_reductemp) if (fd->have_reductemp)
{ {
...@@ -3540,7 +3547,7 @@ expand_omp_for_static_nochunk (struct omp_region *region, ...@@ -3540,7 +3547,7 @@ expand_omp_for_static_nochunk (struct omp_region *region,
tree *counts = NULL; tree *counts = NULL;
tree n1, n2, step; tree n1, n2, step;
tree reductions = NULL_TREE; tree reductions = NULL_TREE;
tree cond_var = NULL_TREE; tree cond_var = NULL_TREE, condtemp = NULL_TREE;
itype = type = TREE_TYPE (fd->loop.v); itype = type = TREE_TYPE (fd->loop.v);
if (POINTER_TYPE_P (type)) if (POINTER_TYPE_P (type))
...@@ -3626,7 +3633,16 @@ expand_omp_for_static_nochunk (struct omp_region *region, ...@@ -3626,7 +3633,16 @@ expand_omp_for_static_nochunk (struct omp_region *region,
gsi = gsi_last_bb (entry_bb); gsi = gsi_last_bb (entry_bb);
} }
if (fd->have_reductemp || fd->lastprivate_conditional) if (fd->lastprivate_conditional)
{
tree clauses = gimple_omp_for_clauses (fd->for_stmt);
tree c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_);
if (fd->have_pointer_condtemp)
condtemp = OMP_CLAUSE_DECL (c);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_);
cond_var = OMP_CLAUSE_DECL (c);
}
if (fd->have_reductemp || fd->have_pointer_condtemp)
{ {
tree t1 = build_int_cst (long_integer_type_node, 0); tree t1 = build_int_cst (long_integer_type_node, 0);
tree t2 = build_int_cst (long_integer_type_node, 1); tree t2 = build_int_cst (long_integer_type_node, 1);
...@@ -3636,7 +3652,6 @@ expand_omp_for_static_nochunk (struct omp_region *region, ...@@ -3636,7 +3652,6 @@ expand_omp_for_static_nochunk (struct omp_region *region,
gimple_stmt_iterator gsi2 = gsi_none (); gimple_stmt_iterator gsi2 = gsi_none ();
gimple *g = NULL; gimple *g = NULL;
tree mem = null_pointer_node, memv = NULL_TREE; tree mem = null_pointer_node, memv = NULL_TREE;
tree condtemp = NULL_TREE;
if (fd->have_reductemp) if (fd->have_reductemp)
{ {
tree c = omp_find_clause (clauses, OMP_CLAUSE__REDUCTEMP_); tree c = omp_find_clause (clauses, OMP_CLAUSE__REDUCTEMP_);
...@@ -3655,12 +3670,8 @@ expand_omp_for_static_nochunk (struct omp_region *region, ...@@ -3655,12 +3670,8 @@ expand_omp_for_static_nochunk (struct omp_region *region,
gsi2 = gsip; gsi2 = gsip;
reductions = null_pointer_node; reductions = null_pointer_node;
} }
if (fd->lastprivate_conditional) if (fd->have_pointer_condtemp)
{ {
tree c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_);
condtemp = OMP_CLAUSE_DECL (c);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_);
cond_var = OMP_CLAUSE_DECL (c);
tree type = TREE_TYPE (condtemp); tree type = TREE_TYPE (condtemp);
memv = create_tmp_var (type); memv = create_tmp_var (type);
TREE_ADDRESSABLE (memv) = 1; TREE_ADDRESSABLE (memv) = 1;
...@@ -3677,7 +3688,7 @@ expand_omp_for_static_nochunk (struct omp_region *region, ...@@ -3677,7 +3688,7 @@ expand_omp_for_static_nochunk (struct omp_region *region,
null_pointer_node, reductions, mem); null_pointer_node, reductions, mem);
force_gimple_operand_gsi (&gsi2, t, true, NULL_TREE, force_gimple_operand_gsi (&gsi2, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
if (fd->lastprivate_conditional) if (fd->have_pointer_condtemp)
expand_omp_build_assign (&gsi2, condtemp, memv, false); expand_omp_build_assign (&gsi2, condtemp, memv, false);
if (fd->have_reductemp) if (fd->have_reductemp)
{ {
...@@ -3999,7 +4010,7 @@ expand_omp_for_static_nochunk (struct omp_region *region, ...@@ -3999,7 +4010,7 @@ expand_omp_for_static_nochunk (struct omp_region *region,
if (!gimple_omp_return_nowait_p (gsi_stmt (gsi))) if (!gimple_omp_return_nowait_p (gsi_stmt (gsi)))
{ {
t = gimple_omp_return_lhs (gsi_stmt (gsi)); t = gimple_omp_return_lhs (gsi_stmt (gsi));
if (fd->have_reductemp || fd->lastprivate_conditional) if (fd->have_reductemp || fd->have_pointer_condtemp)
{ {
tree fn; tree fn;
if (t) if (t)
...@@ -4156,7 +4167,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -4156,7 +4167,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
tree *counts = NULL; tree *counts = NULL;
tree n1, n2, step; tree n1, n2, step;
tree reductions = NULL_TREE; tree reductions = NULL_TREE;
tree cond_var = NULL_TREE; tree cond_var = NULL_TREE, condtemp = NULL_TREE;
itype = type = TREE_TYPE (fd->loop.v); itype = type = TREE_TYPE (fd->loop.v);
if (POINTER_TYPE_P (type)) if (POINTER_TYPE_P (type))
...@@ -4246,7 +4257,16 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -4246,7 +4257,16 @@ expand_omp_for_static_chunk (struct omp_region *region,
gsi = gsi_last_bb (entry_bb); gsi = gsi_last_bb (entry_bb);
} }
if (fd->have_reductemp || fd->lastprivate_conditional) if (fd->lastprivate_conditional)
{
tree clauses = gimple_omp_for_clauses (fd->for_stmt);
tree c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_);
if (fd->have_pointer_condtemp)
condtemp = OMP_CLAUSE_DECL (c);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_);
cond_var = OMP_CLAUSE_DECL (c);
}
if (fd->have_reductemp || fd->have_pointer_condtemp)
{ {
tree t1 = build_int_cst (long_integer_type_node, 0); tree t1 = build_int_cst (long_integer_type_node, 0);
tree t2 = build_int_cst (long_integer_type_node, 1); tree t2 = build_int_cst (long_integer_type_node, 1);
...@@ -4256,7 +4276,6 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -4256,7 +4276,6 @@ expand_omp_for_static_chunk (struct omp_region *region,
gimple_stmt_iterator gsi2 = gsi_none (); gimple_stmt_iterator gsi2 = gsi_none ();
gimple *g = NULL; gimple *g = NULL;
tree mem = null_pointer_node, memv = NULL_TREE; tree mem = null_pointer_node, memv = NULL_TREE;
tree condtemp = NULL_TREE;
if (fd->have_reductemp) if (fd->have_reductemp)
{ {
tree c = omp_find_clause (clauses, OMP_CLAUSE__REDUCTEMP_); tree c = omp_find_clause (clauses, OMP_CLAUSE__REDUCTEMP_);
...@@ -4275,12 +4294,8 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -4275,12 +4294,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
gsi2 = gsip; gsi2 = gsip;
reductions = null_pointer_node; reductions = null_pointer_node;
} }
if (fd->lastprivate_conditional) if (fd->have_pointer_condtemp)
{ {
tree c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_);
condtemp = OMP_CLAUSE_DECL (c);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_);
cond_var = OMP_CLAUSE_DECL (c);
tree type = TREE_TYPE (condtemp); tree type = TREE_TYPE (condtemp);
memv = create_tmp_var (type); memv = create_tmp_var (type);
TREE_ADDRESSABLE (memv) = 1; TREE_ADDRESSABLE (memv) = 1;
...@@ -4297,7 +4312,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -4297,7 +4312,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
null_pointer_node, reductions, mem); null_pointer_node, reductions, mem);
force_gimple_operand_gsi (&gsi2, t, true, NULL_TREE, force_gimple_operand_gsi (&gsi2, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
if (fd->lastprivate_conditional) if (fd->have_pointer_condtemp)
expand_omp_build_assign (&gsi2, condtemp, memv, false); expand_omp_build_assign (&gsi2, condtemp, memv, false);
if (fd->have_reductemp) if (fd->have_reductemp)
{ {
...@@ -4635,7 +4650,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -4635,7 +4650,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
if (!gimple_omp_return_nowait_p (gsi_stmt (gsi))) if (!gimple_omp_return_nowait_p (gsi_stmt (gsi)))
{ {
t = gimple_omp_return_lhs (gsi_stmt (gsi)); t = gimple_omp_return_lhs (gsi_stmt (gsi));
if (fd->have_reductemp || fd->lastprivate_conditional) if (fd->have_reductemp || fd->have_pointer_condtemp)
{ {
tree fn; tree fn;
if (t) if (t)
...@@ -6263,7 +6278,7 @@ expand_omp_for (struct omp_region *region, gimple *inner_stmt) ...@@ -6263,7 +6278,7 @@ expand_omp_for (struct omp_region *region, gimple *inner_stmt)
else else
start_ix = ((int)BUILT_IN_GOMP_LOOP_STATIC_START) + fn_index; start_ix = ((int)BUILT_IN_GOMP_LOOP_STATIC_START) + fn_index;
next_ix = ((int)BUILT_IN_GOMP_LOOP_STATIC_NEXT) + fn_index; next_ix = ((int)BUILT_IN_GOMP_LOOP_STATIC_NEXT) + fn_index;
if (fd.have_reductemp || fd.lastprivate_conditional) if (fd.have_reductemp || fd.have_pointer_condtemp)
{ {
if (fd.ordered) if (fd.ordered)
start_ix = (int)BUILT_IN_GOMP_LOOP_DOACROSS_START; start_ix = (int)BUILT_IN_GOMP_LOOP_DOACROSS_START;
......
...@@ -168,6 +168,7 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd, ...@@ -168,6 +168,7 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
fd->have_nowait = distribute || simd; fd->have_nowait = distribute || simd;
fd->have_ordered = false; fd->have_ordered = false;
fd->have_reductemp = false; fd->have_reductemp = false;
fd->have_pointer_condtemp = false;
fd->lastprivate_conditional = 0; fd->lastprivate_conditional = 0;
fd->tiling = NULL_TREE; fd->tiling = NULL_TREE;
fd->collapse = 1; fd->collapse = 1;
...@@ -226,6 +227,10 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd, ...@@ -226,6 +227,10 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (t)) if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (t))
fd->lastprivate_conditional++; fd->lastprivate_conditional++;
break; break;
case OMP_CLAUSE__CONDTEMP_:
if (POINTER_TYPE_P (TREE_TYPE (OMP_CLAUSE_DECL (t))))
fd->have_pointer_condtemp = true;
break;
default: default:
break; break;
} }
......
...@@ -63,6 +63,7 @@ struct omp_for_data ...@@ -63,6 +63,7 @@ struct omp_for_data
int collapse; /* Collapsed loops, 1 for a non-collapsed loop. */ int collapse; /* Collapsed loops, 1 for a non-collapsed loop. */
int ordered; int ordered;
bool have_nowait, have_ordered, simd_schedule, have_reductemp; bool have_nowait, have_ordered, simd_schedule, have_reductemp;
bool have_pointer_condtemp;
int lastprivate_conditional; int lastprivate_conditional;
unsigned char sched_modifiers; unsigned char sched_modifiers;
enum omp_clause_schedule_kind sched_kind; enum omp_clause_schedule_kind sched_kind;
......
...@@ -1413,6 +1413,15 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) ...@@ -1413,6 +1413,15 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
install_var_local (decl, ctx); install_var_local (decl, ctx);
break; break;
case OMP_CLAUSE__CONDTEMP_:
if (is_parallel_ctx (ctx))
{
decl = OMP_CLAUSE_DECL (c);
install_var_field (decl, false, 3, ctx);
install_var_local (decl, ctx);
}
break;
case OMP_CLAUSE__CACHE_: case OMP_CLAUSE__CACHE_:
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -1587,6 +1596,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) ...@@ -1587,6 +1596,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
case OMP_CLAUSE__SIMT_: case OMP_CLAUSE__SIMT_:
case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_IF_PRESENT:
case OMP_CLAUSE_FINALIZE: case OMP_CLAUSE_FINALIZE:
case OMP_CLAUSE__CONDTEMP_:
break; break;
case OMP_CLAUSE__CACHE_: case OMP_CLAUSE__CACHE_:
...@@ -4041,6 +4051,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, ...@@ -4041,6 +4051,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
DECL_HAS_VALUE_EXPR_P (new_var) = 1; DECL_HAS_VALUE_EXPR_P (new_var) = 1;
} }
continue; continue;
case OMP_CLAUSE__CONDTEMP_:
if (is_parallel_ctx (ctx))
break;
continue;
default: default:
continue; continue;
} }
...@@ -4707,6 +4721,15 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, ...@@ -4707,6 +4721,15 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
TREE_NO_WARNING (var) = 1; TREE_NO_WARNING (var) = 1;
break; break;
case OMP_CLAUSE__CONDTEMP_:
if (is_parallel_ctx (ctx))
{
x = build_receiver_ref (var, false, ctx);
SET_DECL_VALUE_EXPR (new_var, x);
DECL_HAS_VALUE_EXPR_P (new_var) = 1;
}
break;
case OMP_CLAUSE_LASTPRIVATE: case OMP_CLAUSE_LASTPRIVATE:
if (OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c)) if (OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c))
break; break;
...@@ -5388,25 +5411,36 @@ lower_lastprivate_conditional_clauses (tree *clauses, omp_context *ctx) ...@@ -5388,25 +5411,36 @@ lower_lastprivate_conditional_clauses (tree *clauses, omp_context *ctx)
} }
else if (gimple_code (ctx->stmt) == GIMPLE_OMP_SECTIONS) else if (gimple_code (ctx->stmt) == GIMPLE_OMP_SECTIONS)
iter_type = unsigned_type_node; iter_type = unsigned_type_node;
cond_ptr = create_tmp_var_raw (build_pointer_type (iter_type)); tree c2 = omp_find_clause (*clauses, OMP_CLAUSE__CONDTEMP_);
DECL_CONTEXT (cond_ptr) = current_function_decl; if (c2)
DECL_SEEN_IN_BIND_EXPR_P (cond_ptr) = 1; {
DECL_CHAIN (cond_ptr) = ctx->block_vars; cond_ptr
ctx->block_vars = cond_ptr; = lookup_decl_in_outer_ctx (OMP_CLAUSE_DECL (c2), ctx);
OMP_CLAUSE_DECL (c2) = cond_ptr;
}
else
{
cond_ptr = create_tmp_var_raw (build_pointer_type (iter_type));
DECL_CONTEXT (cond_ptr) = current_function_decl;
DECL_SEEN_IN_BIND_EXPR_P (cond_ptr) = 1;
DECL_CHAIN (cond_ptr) = ctx->block_vars;
ctx->block_vars = cond_ptr;
c2 = build_omp_clause (UNKNOWN_LOCATION,
OMP_CLAUSE__CONDTEMP_);
OMP_CLAUSE_DECL (c2) = cond_ptr;
OMP_CLAUSE_CHAIN (c2) = *clauses;
*clauses = c2;
}
iter_var = create_tmp_var_raw (iter_type); iter_var = create_tmp_var_raw (iter_type);
DECL_CONTEXT (iter_var) = current_function_decl; DECL_CONTEXT (iter_var) = current_function_decl;
DECL_SEEN_IN_BIND_EXPR_P (iter_var) = 1; DECL_SEEN_IN_BIND_EXPR_P (iter_var) = 1;
DECL_CHAIN (iter_var) = ctx->block_vars; DECL_CHAIN (iter_var) = ctx->block_vars;
ctx->block_vars = iter_var; ctx->block_vars = iter_var;
tree c2
= build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE__CONDTEMP_);
tree c3 tree c3
= build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE__CONDTEMP_); = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE__CONDTEMP_);
OMP_CLAUSE_DECL (c2) = cond_ptr;
OMP_CLAUSE_DECL (c3) = iter_var; OMP_CLAUSE_DECL (c3) = iter_var;
OMP_CLAUSE_CHAIN (c3) = OMP_CLAUSE_CHAIN (c2);
OMP_CLAUSE_CHAIN (c2) = c3; OMP_CLAUSE_CHAIN (c2) = c3;
OMP_CLAUSE_CHAIN (c3) = *clauses;
*clauses = c2;
ctx->lastprivate_conditional_map = new hash_map<tree, tree>; ctx->lastprivate_conditional_map = new hash_map<tree, tree>;
} }
tree v = create_tmp_var_raw (iter_type); tree v = create_tmp_var_raw (iter_type);
...@@ -5536,11 +5570,18 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *body_p, ...@@ -5536,11 +5570,18 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *body_p,
tree v = *ctx->lastprivate_conditional_map->get (o); tree v = *ctx->lastprivate_conditional_map->get (o);
gimplify_assign (v, build_zero_cst (type), body_p); gimplify_assign (v, build_zero_cst (type), body_p);
this_stmt_list = cstmt_list; this_stmt_list = cstmt_list;
tree mem = build2 (MEM_REF, type, cond_ptr, tree mem;
build_int_cst (TREE_TYPE (cond_ptr), if (POINTER_TYPE_P (TREE_TYPE (cond_ptr)))
conditional_off)); {
mem = build2 (MEM_REF, type, cond_ptr,
build_int_cst (TREE_TYPE (cond_ptr),
conditional_off));
conditional_off += tree_to_uhwi (TYPE_SIZE_UNIT (type));
}
else
mem = build4 (ARRAY_REF, type, cond_ptr,
size_int (conditional_off++), NULL_TREE, NULL_TREE);
tree mem2 = copy_node (mem); tree mem2 = copy_node (mem);
conditional_off += tree_to_uhwi (TYPE_SIZE_UNIT (type));
gimple_seq seq = NULL; gimple_seq seq = NULL;
mem = force_gimple_operand (mem, &seq, true, NULL_TREE); mem = force_gimple_operand (mem, &seq, true, NULL_TREE);
gimple_seq_add_seq (this_stmt_list, seq); gimple_seq_add_seq (this_stmt_list, seq);
...@@ -6448,7 +6489,16 @@ lower_send_shared_vars (gimple_seq *ilist, gimple_seq *olist, omp_context *ctx) ...@@ -6448,7 +6489,16 @@ lower_send_shared_vars (gimple_seq *ilist, gimple_seq *olist, omp_context *ctx)
if (use_pointer_for_field (ovar, ctx)) if (use_pointer_for_field (ovar, ctx))
{ {
x = build_sender_ref (ovar, ctx); x = build_sender_ref (ovar, ctx);
var = build_fold_addr_expr (var); if (TREE_CODE (TREE_TYPE (f)) == ARRAY_TYPE
&& TREE_TYPE (f) == TREE_TYPE (ovar))
{
gcc_assert (is_parallel_ctx (ctx)
&& DECL_ARTIFICIAL (ovar));
/* _condtemp_ clause. */
var = build_constructor (TREE_TYPE (x), NULL);
}
else
var = build_fold_addr_expr (var);
gimplify_assign (x, var, ilist); gimplify_assign (x, var, ilist);
} }
else else
...@@ -10652,7 +10702,10 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx) ...@@ -10652,7 +10702,10 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
if (gimple_code (up->stmt) == GIMPLE_OMP_ORDERED if (gimple_code (up->stmt) == GIMPLE_OMP_ORDERED
|| gimple_code (up->stmt) == GIMPLE_OMP_CRITICAL || gimple_code (up->stmt) == GIMPLE_OMP_CRITICAL
|| gimple_code (up->stmt) == GIMPLE_OMP_TASKGROUP || gimple_code (up->stmt) == GIMPLE_OMP_TASKGROUP
|| gimple_code (up->stmt) == GIMPLE_OMP_SECTION) || gimple_code (up->stmt) == GIMPLE_OMP_SECTION
|| (gimple_code (up->stmt) == GIMPLE_OMP_TARGET
&& (gimple_omp_target_kind (up->stmt)
== GF_OMP_TARGET_KIND_DATA)))
continue; continue;
else if (!up->lastprivate_conditional_map) else if (!up->lastprivate_conditional_map)
break; break;
......
...@@ -1348,6 +1348,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) ...@@ -1348,6 +1348,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
case OMP_CLAUSE_AUTO: case OMP_CLAUSE_AUTO:
case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_IF_PRESENT:
case OMP_CLAUSE_FINALIZE: case OMP_CLAUSE_FINALIZE:
case OMP_CLAUSE__CONDTEMP_:
break; break;
/* The following clause belongs to the OpenACC cache directive, which /* The following clause belongs to the OpenACC cache directive, which
...@@ -1369,7 +1370,6 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) ...@@ -1369,7 +1370,6 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
function decomposition happens before that. */ function decomposition happens before that. */
case OMP_CLAUSE__LOOPTEMP_: case OMP_CLAUSE__LOOPTEMP_:
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
case OMP_CLAUSE__CONDTEMP_:
case OMP_CLAUSE__SIMDUID_: case OMP_CLAUSE__SIMDUID_:
case OMP_CLAUSE__GRIDDIM_: case OMP_CLAUSE__GRIDDIM_:
case OMP_CLAUSE__SIMT_: case OMP_CLAUSE__SIMT_:
...@@ -2076,6 +2076,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) ...@@ -2076,6 +2076,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
case OMP_CLAUSE_AUTO: case OMP_CLAUSE_AUTO:
case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_IF_PRESENT:
case OMP_CLAUSE_FINALIZE: case OMP_CLAUSE_FINALIZE:
case OMP_CLAUSE__CONDTEMP_:
break; break;
/* The following clause belongs to the OpenACC cache directive, which /* The following clause belongs to the OpenACC cache directive, which
...@@ -2097,7 +2098,6 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) ...@@ -2097,7 +2098,6 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
function decomposition happens before that. */ function decomposition happens before that. */
case OMP_CLAUSE__LOOPTEMP_: case OMP_CLAUSE__LOOPTEMP_:
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
case OMP_CLAUSE__CONDTEMP_:
case OMP_CLAUSE__SIMDUID_: case OMP_CLAUSE__SIMDUID_:
case OMP_CLAUSE__GRIDDIM_: case OMP_CLAUSE__GRIDDIM_:
case OMP_CLAUSE__SIMT_: case OMP_CLAUSE__SIMT_:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment