* gimplify.c (gimplify_bind_expr): In ORT_SIMD region
mark local addressable non-static vars as GOVD_PRIVATE
instead of GOVD_LOCAL.
* omp-low.c (lower_omp_for): Move gimple_bind_vars
and BLOCK_VARS of gimple_bind_block to new_stmt rather
than copying them.
* gcc.dg/vect/pr59984.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207629
138bc75d-0d04-0410-961f-
82ee72b054a4
2014-02-08 Jakub Jelinek <jakub@redhat.com>
+ PR c/59984
+ * gimplify.c (gimplify_bind_expr): In ORT_SIMD region
+ mark local addressable non-static vars as GOVD_PRIVATE
+ instead of GOVD_LOCAL.
+ * omp-low.c (lower_omp_for): Move gimple_bind_vars
+ and BLOCK_VARS of gimple_bind_block to new_stmt rather
+ than copying them.
+
PR middle-end/60092
* tree-ssa-ccp.c (surely_varying_stmt_p): Don't return true
if TYPE_ATTRIBUTES (gimple_call_fntype ()) contain
&& (! DECL_SEEN_IN_BIND_EXPR_P (t)
|| splay_tree_lookup (ctx->variables,
(splay_tree_key) t) == NULL))
- omp_add_variable (gimplify_omp_ctxp, t, GOVD_LOCAL | GOVD_SEEN);
+ {
+ 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);
+ }
DECL_SEEN_IN_BIND_EXPR_P (t) = 1;
if (!gimple_seq_empty_p (omp_for_body)
&& gimple_code (gimple_seq_first_stmt (omp_for_body)) == GIMPLE_BIND)
{
- tree vars = gimple_bind_vars (gimple_seq_first_stmt (omp_for_body));
+ gimple inner_bind = gimple_seq_first_stmt (omp_for_body);
+ tree vars = gimple_bind_vars (inner_bind);
gimple_bind_append_vars (new_stmt, vars);
+ /* bind_vars/BLOCK_VARS are being moved to new_stmt/block, don't
+ keep them on the inner_bind and it's block. */
+ gimple_bind_set_vars (inner_bind, NULL_TREE);
+ if (gimple_bind_block (inner_bind))
+ BLOCK_VARS (gimple_bind_block (inner_bind)) = NULL_TREE;
}
if (gimple_omp_for_combined_into_p (stmt))
2014-02-08 Jakub Jelinek <jakub@redhat.com>
+ PR c/59984
+ * gcc.dg/vect/pr59984.c: New test.
+
PR middle-end/60092
* gcc.dg/attr-alloc_align-1.c: New test.
* gcc.dg/attr-alloc_align-2.c: New test.
--- /dev/null
+/* PR c/59984 */
+/* { dg-additional-options "-fopenmp-simd" } */
+
+#include "tree-vect.h"
+
+#define N 128
+
+int a[N];
+
+#pragma omp declare simd
+__attribute__((noinline)) void
+foo (int in, int *out1, int *out2)
+{
+ *out1 = in * in - 1;
+ *out2 = in * in + 1;
+}
+
+#pragma omp declare simd linear (out1, out2)
+__attribute__((noinline)) void
+bar (int in, int *out1, int *out2)
+{
+ *out1 = in * in - 1;
+ *out2 = in * in + 1;
+}
+
+__attribute__((noinline)) void
+test (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ a[i] = i;
+#pragma omp simd
+ for (i = 0; i < N; i++)
+ {
+ int v1, v2;
+ foo (a[i], &v1, &v2);
+ a[i] = v1 * v2;
+ }
+ for (i = 0; i < N; i++)
+ if (a[i] != i * i * i * i - 1)
+ __builtin_abort ();
+ for (i = 0; i < N; i++)
+ a[i] = i;
+#pragma omp simd
+ for (i = 0; i < N; i++)
+ {
+ int v1, v2;
+ bar (a[i], &v1, &v2);
+ a[i] = v1 * v2;
+ }
+ for (i = 0; i < N; i++)
+ if (a[i] != i * i * i * i - 1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ check_vect ();
+ test ();
+ return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */