aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-07-04 23:41:49 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-07-04 23:41:49 +0200
commitec03bc90e5bdb772e2f19ec352fc4b2e985e4c91 (patch)
treec7a12300601b050ad3e64d33de63243d7f4b7f90 /gcc
parent2f03073ff24bbb005d52db7e2b7a5ea32bb01140 (diff)
downloadgcc-ec03bc90e5bdb772e2f19ec352fc4b2e985e4c91.zip
gcc-ec03bc90e5bdb772e2f19ec352fc4b2e985e4c91.tar.gz
gcc-ec03bc90e5bdb772e2f19ec352fc4b2e985e4c91.tar.bz2
re PR middle-end/78884 ([7/8] ICE when gimplifying VLA in OpenMP SIMD region)
PR middle-end/78884 * gimplify.c (struct gimplify_omp_ctx): Add add_safelen1 member. (gimplify_bind_expr): If seeing TREE_ADDRESSABLE VLA inside of simd loop body, set ctx->add_safelen1 instead of making it GOVD_PRIVATE. (gimplify_adjust_omp_clauses): Add safelen (1) clause if ctx->add_safelen1 is set. * gcc.dg/gomp/pr78884.c: New test. From-SVN: r273096
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimplify.c24
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr78884.c16
4 files changed, 49 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c51ba75..5145487 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2019-07-04 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/78884
+ * gimplify.c (struct gimplify_omp_ctx): Add add_safelen1 member.
+ (gimplify_bind_expr): If seeing TREE_ADDRESSABLE VLA inside of simd
+ loop body, set ctx->add_safelen1 instead of making it GOVD_PRIVATE.
+ (gimplify_adjust_omp_clauses): Add safelen (1) clause if
+ ctx->add_safelen1 is set.
+
* omp-expand.c (expand_omp_for_static_nochunk): Don't emit
GOMP_loop_start at the start of second worksharing loop in a scan.
For nowait, don't emit GOMP_loop_end_nowait at the end of first
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index a3792d1..239988b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -221,6 +221,7 @@ struct gimplify_omp_ctx
bool combined_loop;
bool distribute;
bool target_firstprivatize_array_bases;
+ bool add_safelen1;
int defaultmap[4];
};
@@ -1331,12 +1332,17 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
|| splay_tree_lookup (ctx->variables,
(splay_tree_key) t) == NULL)
{
+ int flag = GOVD_LOCAL;
if (ctx->region_type == ORT_SIMD
&& TREE_ADDRESSABLE (t)
&& !TREE_STATIC (t))
- omp_add_variable (ctx, t, GOVD_PRIVATE | GOVD_SEEN);
- else
- omp_add_variable (ctx, t, GOVD_LOCAL | GOVD_SEEN);
+ {
+ if (TREE_CODE (DECL_SIZE_UNIT (t)) != INTEGER_CST)
+ ctx->add_safelen1 = true;
+ else
+ flag = GOVD_PRIVATE;
+ }
+ omp_add_variable (ctx, t, flag | GOVD_SEEN);
}
/* Static locals inside of target construct or offloaded
routines need to be "omp declare target". */
@@ -9801,6 +9807,18 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
}
}
+ if (ctx->add_safelen1)
+ {
+ /* If there are VLAs in the body of simd loop, prevent
+ vectorization. */
+ gcc_assert (ctx->region_type == ORT_SIMD);
+ c = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE_SAFELEN);
+ OMP_CLAUSE_SAFELEN_EXPR (c) = integer_one_node;
+ OMP_CLAUSE_CHAIN (c) = *list_p;
+ *list_p = c;
+ list_p = &OMP_CLAUSE_CHAIN (c);
+ }
+
if (ctx->region_type == ORT_WORKSHARE
&& ctx->outer_context
&& ctx->outer_context->region_type == ORT_COMBINED_PARALLEL)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 73847a9..30b2d1f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/78884
+ * gcc.dg/gomp/pr78884.c: New test.
+
2019-07-04 Andrea Corallo <andrea.corallo@arm.com>
* jit.dg/test-error-gcc_jit_context_new_binary_op-bad-res-type.c:
diff --git a/gcc/testsuite/gcc.dg/gomp/pr78884.c b/gcc/testsuite/gcc.dg/gomp/pr78884.c
new file mode 100644
index 0000000..3e03df5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr78884.c
@@ -0,0 +1,16 @@
+/* PR middle-end/78884 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp" } */
+
+void bar (int *);
+
+void
+foo (int n)
+{
+#pragma omp simd
+ for (int i = 0; i < 1024; i++)
+ {
+ int vla[n];
+ bar (vla);
+ }
+}