[openacc] Fix ICE when compiling tile loop containing infinite loop
authorCesar Philippidis <cesar@codesourcery.com>
Mon, 16 Apr 2018 18:01:09 +0000 (11:01 -0700)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 16 Apr 2018 18:01:09 +0000 (18:01 +0000)
2018-04-16  Cesar Philippidis  <cesar@codesourcery.com>
    Tom de Vries  <tom@codesourcery.com>

PR middle-end/84955
* omp-expand.c (expand_oacc_for): Add dummy false branch for
tiled basic blocks without omp continue statements.

* testsuite/libgomp.oacc-c-c++-common/pr84955.c: New test.
* testsuite/libgomp.oacc-fortran/pr84955.f90: New test.

Co-Authored-By: Tom de Vries <tom@codesourcery.com>
From-SVN: r259406

gcc/ChangeLog
gcc/omp-expand.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c-c++-common/pr84955.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-fortran/pr84955.f90 [new file with mode: 0644]

index c3ea8d62e4366f5e76298512df941346d1cf2d03..caef3054ec68ba65ebfe1f9cf7049234fa85800f 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-16  Cesar Philippidis  <cesar@codesourcery.com>
+           Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/84955
+       * omp-expand.c (expand_oacc_for): Add dummy false branch for
+       tiled basic blocks without omp continue statements.
+
 2018-04-16  Aaron Sawdey  <acsawdey@linux.ibm.com>
 
        PR target/83660
index bb204906ea64efa94a78b42bbc606c0e61f29192..c7d30ea39641e24bc618de6c186862aaf74c2841 100644 (file)
@@ -5439,6 +5439,14 @@ expand_oacc_for (struct omp_region *region, struct omp_for_data *fd)
 
          split->flags ^= EDGE_FALLTHRU | EDGE_TRUE_VALUE;
 
+         /* Add a dummy exit for the tiled block when cont_bb is missing.  */
+         if (cont_bb == NULL)
+           {
+             edge e = make_edge (body_bb, exit_bb, EDGE_FALSE_VALUE);
+             e->probability = profile_probability::even ();
+             split->probability = profile_probability::even ();
+           }
+
          /* Initialize the user's loop vars.  */
          gsi = gsi_start_bb (elem_body_bb);
          expand_oacc_collapse_vars (fd, true, &gsi, counts, e_offset);
index 9568a73738ef4f0b46b9e212131aac81dba63487..ef528093c124b9a316f3e979f417b1297c70cce4 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-16  Cesar Philippidis  <cesar@codesourcery.com>
+           Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/84955
+       * testsuite/libgomp.oacc-c-c++-common/pr84955.c: New test.
+       * testsuite/libgomp.oacc-fortran/pr84955.f90: New test.
+
 2018-04-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/83064
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84955.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84955.c
new file mode 100644 (file)
index 0000000..e528faa
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile }  */
+
+int
+main (void)
+{
+  int i, j;
+
+#pragma acc parallel loop tile(2,3)
+  for (i = 1; i < 10; i++)
+    for (j = 1; j < 10; j++)
+      for (;;)
+       ;
+
+  return i + j;
+}
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/pr84955.f90 b/libgomp/testsuite/libgomp.oacc-fortran/pr84955.f90
new file mode 100644 (file)
index 0000000..dc85865
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do compile }
+
+subroutine s
+   integer :: i, j
+   !$acc parallel loop tile(2,3)
+   do i = 1, 10
+      do j = 1, 10
+         do
+         end do
+      end do
+   end do
+  !$acc end parallel loop
+end subroutine s