public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r8-10868] openmp: Fix ICE with broken doacross loop [PR98205]
@ 2021-04-22 16:49 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-04-22 16:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a66e756ea9cf1ce8f2c73bd29bfe7ed785fae89a

commit r8-10868-ga66e756ea9cf1ce8f2c73bd29bfe7ed785fae89a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 10 11:07:07 2020 +0100

    openmp: Fix ICE with broken doacross loop [PR98205]
    
    If the loop body doesn't ever continue, we don't have a bb to insert the
    updates.  Fixed by not adding them at all in that case.
    
    2020-12-10  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/98205
            * omp-expand.c (expand_omp_for_generic): Fix up broken_loop handling.
    
            * c-c++-common/gomp/doacross-4.c: New test.
    
    (cherry picked from commit c925d4cebf817905c237aa2d93887f254b4a74f4)

Diff:
---
 gcc/omp-expand.c                             | 19 +++++++++++-------
 gcc/testsuite/c-c++-common/gomp/doacross-4.c | 30 ++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 4ea260e3f4a..a2ec912323e 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -2994,13 +2994,18 @@ expand_omp_for_generic (struct omp_region *region,
 	  gsi = gsi_last_bb (l0_bb);
 	  expand_omp_build_assign (&gsi, counts[fd->collapse - 1],
 				   istart0, true);
-	  gsi = gsi_last_bb (cont_bb);
-	  t = fold_build2 (PLUS_EXPR, fd->iter_type, counts[fd->collapse - 1],
-			   build_int_cst (fd->iter_type, 1));
-	  expand_omp_build_assign (&gsi, counts[fd->collapse - 1], t);
-	  tree aref = build4 (ARRAY_REF, fd->iter_type, counts[fd->ordered],
-			      size_zero_node, NULL_TREE, NULL_TREE);
-	  expand_omp_build_assign (&gsi, aref, counts[fd->collapse - 1]);
+	  if (cont_bb)
+	    {
+	      gsi = gsi_last_bb (cont_bb);
+	      t = fold_build2 (PLUS_EXPR, fd->iter_type,
+			       counts[fd->collapse - 1],
+			       build_int_cst (fd->iter_type, 1));
+	      expand_omp_build_assign (&gsi, counts[fd->collapse - 1], t);
+	      tree aref = build4 (ARRAY_REF, fd->iter_type,
+				  counts[fd->ordered], size_zero_node,
+				  NULL_TREE, NULL_TREE);
+	      expand_omp_build_assign (&gsi, aref, counts[fd->collapse - 1]);
+	    }
 	  t = counts[fd->collapse - 1];
 	}
       else if (fd->collapse > 1)
diff --git a/gcc/testsuite/c-c++-common/gomp/doacross-4.c b/gcc/testsuite/c-c++-common/gomp/doacross-4.c
new file mode 100644
index 00000000000..a1182e3ce98
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/doacross-4.c
@@ -0,0 +1,30 @@
+/* PR middle-end/98205 */
+
+void baz (int) __attribute__((noreturn));
+
+void
+foo (int n)
+{
+  int i;
+  #pragma omp for ordered(1)
+  for (i = 0; i < 8; i += n)
+    {
+      #pragma omp ordered depend(source)
+      #pragma omp ordered depend(sink: i - 2)
+      baz (i);
+    }
+}
+
+void
+bar (int n)
+{
+  int i, j;
+  #pragma omp for collapse(2) ordered(2)
+  for (i = 0; i < 8; i += n)
+    for (j = 0; j < 8; j += n)
+      {
+        #pragma omp ordered depend(source)
+        #pragma omp ordered depend(sink: i - 2, j + 2)
+        baz (i);
+      }
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-22 16:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 16:49 [gcc r8-10868] openmp: Fix ICE with broken doacross loop [PR98205] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).