aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-09-10 09:31:14 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2015-09-10 09:31:14 +0200
commit499c20bbe466b6c71bda3b2e3eee044e9364911c (patch)
tree5314dbf71c08c4e14ef596421585661fede2a7e5 /gcc
parent4e4d2c41b9921ee5b8aa8e9d5874da8786e45559 (diff)
downloadgcc-499c20bbe466b6c71bda3b2e3eee044e9364911c.zip
gcc-499c20bbe466b6c71bda3b2e3eee044e9364911c.tar.gz
gcc-499c20bbe466b6c71bda3b2e3eee044e9364911c.tar.bz2
re PR c++/67514 (ICE in omp_add_variable)
PR c++/67514 * gimplify.c (gimplify_omp_for): For loop SIMD construct, if iterator is not explicitly determined, but is defined inside of the combined workshare region, handle it like if it has DECL_EXPR in OMP_FOR_PRE_BODY. * g++.dg/gomp/pr67514.C: New test. From-SVN: r227607
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/gimplify.c33
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr67514.C30
4 files changed, 68 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4bb4e01..4a2a1f3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2015-09-10 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/67514
+ * gimplify.c (gimplify_omp_for): For loop SIMD construct, if
+ iterator is not explicitly determined, but is defined inside
+ of the combined workshare region, handle it like if it has
+ DECL_EXPR in OMP_FOR_PRE_BODY.
+
2015-09-09 Nathan Sidwell <nathan@acm.org>
* config/nvptx/nvptx.md (call_operation): Move bound out of loop.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b7a918b..215ad15 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7123,13 +7123,27 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
OMP_CLAUSE_LINEAR_NO_COPYOUT (c) = 1;
flags |= GOVD_LINEAR_LASTPRIVATE_NO_OUTER;
}
+ struct gimplify_omp_ctx *outer
+ = gimplify_omp_ctxp->outer_context;
+ if (outer && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c))
+ {
+ if (outer->region_type == ORT_WORKSHARE
+ && outer->combined_loop)
+ {
+ n = splay_tree_lookup (outer->variables,
+ (splay_tree_key)decl);
+ if (n != NULL && (n->value & GOVD_LOCAL) != 0)
+ {
+ OMP_CLAUSE_LINEAR_NO_COPYOUT (c) = 1;
+ flags |= GOVD_LINEAR_LASTPRIVATE_NO_OUTER;
+ }
+ }
+ }
+
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = OMP_FOR_CLAUSES (for_stmt);
OMP_FOR_CLAUSES (for_stmt) = c;
-
omp_add_variable (gimplify_omp_ctxp, decl, flags);
- struct gimplify_omp_ctx *outer
- = gimplify_omp_ctxp->outer_context;
if (outer && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c))
{
if (outer->region_type == ORT_WORKSHARE
@@ -7166,9 +7180,16 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
if (outer->region_type == ORT_WORKSHARE
&& outer->combined_loop)
{
- if (outer->outer_context
- && (outer->outer_context->region_type
- == ORT_COMBINED_PARALLEL))
+ n = splay_tree_lookup (outer->variables,
+ (splay_tree_key)decl);
+ if (n != NULL && (n->value & GOVD_LOCAL) != 0)
+ {
+ lastprivate = false;
+ outer = NULL;
+ }
+ else if (outer->outer_context
+ && (outer->outer_context->region_type
+ == ORT_COMBINED_PARALLEL))
outer = outer->outer_context;
else if (omp_check_private (outer, decl, false))
outer = NULL;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fba8b15..2d26e55 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2015-09-10 Jakub Jelinek <jakub@redhat.com>
+ PR c++/67514
+ * g++.dg/gomp/pr67514.C: New test.
+
PR c++/67511
* g++.dg/gomp/pr67511.C: New test.
diff --git a/gcc/testsuite/g++.dg/gomp/pr67514.C b/gcc/testsuite/g++.dg/gomp/pr67514.C
new file mode 100644
index 0000000..a631b8b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr67514.C
@@ -0,0 +1,30 @@
+// PR c++/67514
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <class T>
+void
+foo (T x, T y)
+{
+ #pragma omp parallel
+ #pragma omp for simd
+ for (T i = x; i < y; ++i)
+ ;
+ #pragma omp parallel
+ #pragma omp for simd collapse (2)
+ for (T i = x; i < y; ++i)
+ for (T j = x; j < y; j++)
+ ;
+}
+
+void
+bar (int *x, int *y)
+{
+ foo (x, y);
+}
+
+void
+baz (int x, int y)
+{
+ foo (x, y);
+}