re PR middle-end/67521 (ICE when OpenMP loop expressions mention the IV)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Sep 2015 07:32:54 +0000 (09:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Sep 2015 07:32:54 +0000 (09:32 +0200)
PR middle-end/67521
* gimplify.c (gimplify_omp_for): Don't call omp_add_variable
if decl is already in outer->variables.

* c-c++-common/gomp/pr67521.c: New test.

From-SVN: r227609

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr67521.c [new file with mode: 0644]

index 89ec6f399fb5c69eb844239524c2acb1763196ca..3be0e0aef751d4fbec8c72a4590a4fbbf241bc9f 100644 (file)
@@ -1,5 +1,9 @@
 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,
index 2a7da25a9060cc7d0b8590c71076602186bcc249..5030318ddc87316fde0f2d7292a35705a330d18c 100644 (file)
@@ -7163,10 +7163,16 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
                    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);
+                       }
                    }
                }
            }
@@ -7201,10 +7207,16 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
                    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);
+                       }
                    }
                }
 
index 7f00368b2e5c594875466381514b173589a8b995..e055c442c440e38af2790f65108b88b318992c97 100644 (file)
@@ -1,5 +1,8 @@
 2015-09-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/67521
+       * c-c++-common/gomp/pr67521.c: New test.
+
        PR middle-end/67517
        * c-c++-common/gomp/pr67517.c: New test.
 
diff --git a/gcc/testsuite/c-c++-common/gomp/pr67521.c b/gcc/testsuite/c-c++-common/gomp/pr67521.c
new file mode 100644 (file)
index 0000000..b34c117
--- /dev/null
@@ -0,0 +1,20 @@
+/* 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))
+    ;
+}