2015-09-10 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/67521
+ * gimplify.c (gimplify_omp_for): Don't call omp_add_variable
+ if decl is already in outer->variables.
+
PR middle-end/67517
* gimplify.c (gimplify_scan_omp_clauses): Instead of
asserting that decl is not specified in octx->variables,
outer = NULL;
if (outer)
{
- omp_add_variable (outer, decl,
- GOVD_LASTPRIVATE | GOVD_SEEN);
- if (outer->outer_context)
- omp_notice_variable (outer->outer_context, decl, true);
+ n = splay_tree_lookup (outer->variables,
+ (splay_tree_key)decl);
+ if (n == NULL || (n->value & GOVD_DATA_SHARE_CLASS) == 0)
+ {
+ omp_add_variable (outer, decl,
+ GOVD_LASTPRIVATE | GOVD_SEEN);
+ if (outer->outer_context)
+ omp_notice_variable (outer->outer_context, decl,
+ true);
+ }
}
}
}
outer = NULL;
if (outer)
{
- omp_add_variable (outer, decl,
- GOVD_LASTPRIVATE | GOVD_SEEN);
- if (outer->outer_context)
- omp_notice_variable (outer->outer_context, decl, true);
+ n = splay_tree_lookup (outer->variables,
+ (splay_tree_key)decl);
+ if (n == NULL || (n->value & GOVD_DATA_SHARE_CLASS) == 0)
+ {
+ omp_add_variable (outer, decl,
+ GOVD_LASTPRIVATE | GOVD_SEEN);
+ if (outer->outer_context)
+ omp_notice_variable (outer->outer_context, decl,
+ true);
+ }
}
}
--- /dev/null
+/* PR middle-end/67521 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int x)
+{
+ int i = 0;
+ #pragma omp parallel for simd
+ for (i = (i & x); i < 10; i = i + 2)
+ ;
+ i = 0;
+ #pragma omp parallel for simd
+ for (i = 0; i < (i & x) + 10; i = i + 2)
+ ;
+ i = 0;
+ #pragma omp parallel for simd
+ for (i = 0; i < 10; i = i + ((i & x) + 2))
+ ;
+}