aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2014-06-24 07:53:52 +0000
committerJakub Jelinek <jakub@redhat.com>2014-06-24 07:53:52 +0000
commitf889c1ef26626b4a574229c9128476f516989259 (patch)
tree8eeccb0956a7e6b8abafc24234634fa3736769cf /gcc
parentc73cdf3bd9ce5cb0de381c2d2833cf937044ac52 (diff)
* gimplify.c (gimplify_omp_for): For #pragma omp for simd iterator
not mentioned in clauses use private clause if the iterator is declared in #pragma omp for simd, and when adding lastprivate instead, add it to the outer #pragma omp for too. Diagnose if the variable is private in outer context. For simd collapse > 1 loops, replace all iterators with temporaries. * omp-low.c (lower_rec_input_clauses): Handle LINEAR clause the same even in collapse > 1 loops. gcc/c/ * c-parser.c (c_parser_omp_for_loop): For #pragma omp parallel for simd move lastprivate clause from parallel to for rather than simd. gcc/cp/ * parser.c (cp_parser_omp_for_loop): For #pragma omp parallel for simd move lastprivate clause from parallel to for rather than simd. libgomp/ * testsuite/libgomp.c/for-2.c: Define SC to static for #pragma omp for simd testing. * testsuite/libgomp.c/for-2.h (SC): Define if not defined. (N(f5), N(f6), N(f7), N(f8), N(f10), N(f12), N(f14)): Use SC macro. * testsuite/libgomp.c/simd-14.c: New test. * testsuite/libgomp.c/simd-15.c: New test. * testsuite/libgomp.c/simd-16.c: New test. * testsuite/libgomp.c/simd-17.c: New test. * testsuite/libgomp.c++/for-10.C: Define SC to static for #pragma omp for simd testing. * testsuite/libgomp.c++/simd10.C: New test. * testsuite/libgomp.c++/simd11.C: New test. * testsuite/libgomp.c++/simd12.C: New test. * testsuite/libgomp.c++/simd13.C: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@211930 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c13
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/gimplify.c32
-rw-r--r--gcc/omp-low.c32
7 files changed, 86 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d99680af6f2..b82e84021fb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2014-06-24 Jakub Jelinek <jakub@redhat.com>
+ * gimplify.c (gimplify_omp_for): For #pragma omp for simd iterator
+ not mentioned in clauses use private clause if the iterator is
+ declared in #pragma omp for simd, and when adding lastprivate
+ instead, add it to the outer #pragma omp for too. Diagnose
+ if the variable is private in outer context. For simd collapse > 1
+ loops, replace all iterators with temporaries.
+ * omp-low.c (lower_rec_input_clauses): Handle LINEAR clause the
+ same even in collapse > 1 loops.
+
* gimplify.c (gimplify_scan_omp_clauses) <case OMP_CLAUSE_MAP,
OMP_CLAUSE_TO, OMP_CLAUSE_FROM): Make sure OMP_CLAUSE_SIZE is
non-NULL.
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 0972fdebd24..c9372614122 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-24 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.c (c_parser_omp_for_loop): For
+ #pragma omp parallel for simd move lastprivate clause from parallel
+ to for rather than simd.
+
2014-06-23 Marek Polacek <polacek@redhat.com>
* c-typeck.c (parser_build_binary_op): Don't call
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 5fecb488b6a..f83ccb07db4 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -11910,8 +11910,17 @@ c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code,
tree l = build_omp_clause (OMP_CLAUSE_LOCATION (*c),
OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = OMP_CLAUSE_DECL (*c);
- OMP_CLAUSE_CHAIN (l) = clauses;
- clauses = l;
+ if (code == OMP_SIMD)
+ {
+ OMP_CLAUSE_CHAIN (l)
+ = cclauses[C_OMP_CLAUSE_SPLIT_FOR];
+ cclauses[C_OMP_CLAUSE_SPLIT_FOR] = l;
+ }
+ else
+ {
+ OMP_CLAUSE_CHAIN (l) = clauses;
+ clauses = l;
+ }
OMP_CLAUSE_SET_CODE (*c, OMP_CLAUSE_SHARED);
}
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1540c9742cd..170b90b7c75 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-24 Jakub Jelinek <jakub@redhat.com>
+
+ * parser.c (cp_parser_omp_for_loop): For
+ #pragma omp parallel for simd move lastprivate clause from parallel
+ to for rather than simd.
+
2014-06-23 Paolo Carlini <paolo.carlini@oracle.com>
DR 577
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1079832cec2..41200a02fb0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -29418,9 +29418,17 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
change it to shared (decl) in OMP_PARALLEL_CLAUSES. */
tree l = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = real_decl;
- OMP_CLAUSE_CHAIN (l) = clauses;
CP_OMP_CLAUSE_INFO (l) = CP_OMP_CLAUSE_INFO (*c);
- clauses = l;
+ if (code == OMP_SIMD)
+ {
+ OMP_CLAUSE_CHAIN (l) = cclauses[C_OMP_CLAUSE_SPLIT_FOR];
+ cclauses[C_OMP_CLAUSE_SPLIT_FOR] = l;
+ }
+ else
+ {
+ OMP_CLAUSE_CHAIN (l) = clauses;
+ clauses = l;
+ }
OMP_CLAUSE_SET_CODE (*c, OMP_CLAUSE_SHARED);
CP_OMP_CLAUSE_INFO (*c) = NULL;
add_private_clause = false;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 21ddcf7cf9e..69f6d5b9c61 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6810,6 +6810,31 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
bool lastprivate
= (!has_decl_expr
|| !bitmap_bit_p (has_decl_expr, DECL_UID (decl)));
+ if (lastprivate
+ && gimplify_omp_ctxp->outer_context
+ && gimplify_omp_ctxp->outer_context->region_type
+ == ORT_WORKSHARE
+ && gimplify_omp_ctxp->outer_context->combined_loop
+ && !gimplify_omp_ctxp->outer_context->distribute)
+ {
+ struct gimplify_omp_ctx *outer
+ = gimplify_omp_ctxp->outer_context;
+ n = splay_tree_lookup (outer->variables,
+ (splay_tree_key) decl);
+ if (n != NULL
+ && (n->value & GOVD_DATA_SHARE_CLASS) == GOVD_LOCAL)
+ lastprivate = false;
+ else if (omp_check_private (outer, decl, false))
+ error ("lastprivate variable %qE is private in outer "
+ "context", DECL_NAME (decl));
+ else
+ {
+ omp_add_variable (outer, decl,
+ GOVD_LASTPRIVATE | GOVD_SEEN);
+ if (outer->outer_context)
+ omp_notice_variable (outer->outer_context, decl, true);
+ }
+ }
c = build_omp_clause (input_location,
lastprivate ? OMP_CLAUSE_LASTPRIVATE
: OMP_CLAUSE_PRIVATE);
@@ -6829,10 +6854,13 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
/* If DECL is not a gimple register, create a temporary variable to act
as an iteration counter. This is valid, since DECL cannot be
- modified in the body of the loop. */
+ modified in the body of the loop. Similarly for any iteration vars
+ in simd with collapse > 1 where the iterator vars must be
+ lastprivate. */
if (orig_for_stmt != for_stmt)
var = decl;
- else if (!is_gimple_reg (decl))
+ else if (!is_gimple_reg (decl)
+ || (simd && TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) > 1))
{
var = create_tmp_var (TREE_TYPE (decl), get_name (decl));
TREE_OPERAND (t, 0) = var;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index adbd0eb6b26..e70970e8230 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3421,24 +3421,20 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
OMP_CLAUSE__LOOPTEMP_);
gcc_assert (c);
tree l = OMP_CLAUSE_DECL (c);
- if (fd->collapse == 1)
- {
- tree n1 = fd->loop.n1;
- tree step = fd->loop.step;
- tree itype = TREE_TYPE (l);
- if (POINTER_TYPE_P (itype))
- itype = signed_type_for (itype);
- l = fold_build2 (MINUS_EXPR, itype, l, n1);
- if (TYPE_UNSIGNED (itype)
- && fd->loop.cond_code == GT_EXPR)
- l = fold_build2 (TRUNC_DIV_EXPR, itype,
- fold_build1 (NEGATE_EXPR,
- itype, l),
- fold_build1 (NEGATE_EXPR,
- itype, step));
- else
- l = fold_build2 (TRUNC_DIV_EXPR, itype, l, step);
- }
+ tree n1 = fd->loop.n1;
+ tree step = fd->loop.step;
+ tree itype = TREE_TYPE (l);
+ if (POINTER_TYPE_P (itype))
+ itype = signed_type_for (itype);
+ l = fold_build2 (MINUS_EXPR, itype, l, n1);
+ if (TYPE_UNSIGNED (itype)
+ && fd->loop.cond_code == GT_EXPR)
+ l = fold_build2 (TRUNC_DIV_EXPR, itype,
+ fold_build1 (NEGATE_EXPR, itype, l),
+ fold_build1 (NEGATE_EXPR,
+ itype, step));
+ else
+ l = fold_build2 (TRUNC_DIV_EXPR, itype, l, step);
t = fold_build2 (MULT_EXPR, stept,
fold_convert (stept, l), t);
if (POINTER_TYPE_P (TREE_TYPE (x)))