Fortran: Fix clause splitting for OMP masked taskloop directive
authorSandra Loosemore <sandra@codesourcery.com>
Tue, 5 Apr 2022 19:06:56 +0000 (12:06 -0700)
committerSandra Loosemore <sandra@codesourcery.com>
Tue, 5 Apr 2022 19:10:29 +0000 (12:10 -0700)
This patch fixes an obvious coding goof that caused all clauses for
the combined OMP masked taskloop directive to be discarded.

gcc/fortran/
* trans-openmp.cc (gfc_split_omp_clauses): Fix mask for
EXEC_OMP_MASKED_TASKLOOP.

gcc/testsuite/
* gfortran.dg/gomp/masked-taskloop.f90: New.

gcc/fortran/trans-openmp.cc
gcc/testsuite/gfortran.dg/gomp/masked-taskloop.f90 [new file with mode: 0644]

index 101924f..25dde82 100644 (file)
@@ -5998,7 +5998,7 @@ gfc_split_omp_clauses (gfc_code *code,
       innermost = GFC_OMP_SPLIT_DO;
       break;
     case EXEC_OMP_MASKED_TASKLOOP:
-      mask = GFC_OMP_SPLIT_MASKED | GFC_OMP_SPLIT_TASKLOOP;
+      mask = GFC_OMP_MASK_MASKED | GFC_OMP_MASK_TASKLOOP;
       innermost = GFC_OMP_SPLIT_TASKLOOP;
       break;
     case EXEC_OMP_MASTER_TASKLOOP:
diff --git a/gcc/testsuite/gfortran.dg/gomp/masked-taskloop.f90 b/gcc/testsuite/gfortran.dg/gomp/masked-taskloop.f90
new file mode 100644 (file)
index 0000000..5770c59
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! { dg-additional-options "-fopenmp -fdump-tree-original" }
+
+! There was a bug in the clause splitting for the "masked taskloop"
+! combined directive that caused it to lose all the clauses.
+
+subroutine s1 (a1, a2)
+  integer :: a1, a2
+  integer :: i, j
+
+  !$omp masked taskloop collapse(2) grainsize(4)
+  do i = 1, a1
+    do j = 1, a2
+    end do
+  end do
+
+end subroutine
+
+! { dg-final { scan-tree-dump "omp taskloop \[^\n\r]*grainsize\\(4\\)" "original" } }
+! { dg-final { scan-tree-dump "omp taskloop \[^\n\r]*collapse\\(2\\)" "original" } }