On 24/06/2020 6:29 pm, Tobias Burnus wrote:
Hi Kwok,
the TODO is fixed by the attached patch; I would be happy if you could handle
this patch,
e.g. together with your patch – or as follow up.
(Lightly tested only, i.e. it fixes the ICE but I did not
do a full testsuite run. But I regard it as obvious.)
Hello
I have committed your patch along with the testcase as 'obvious'. I have
confirmed that it does not regress the gfortran and libgomp testsuites.
Kwok
commit f530bac8a11da9c85bdd8e58d589747f9825e38d
Author: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Thu Jun 25 04:40:53 2020 -0700
fortran: Fix ICE when 'if' clause used with 'target parallel' (PR95869)
2020-06-25 Tobias Burnus <tob...@codesourcery.com>
Kwok Cheung Yeung <k...@codesourery.com>
gcc/fortran/
PR fortran/95869
* trans-openmp.c (gfc_trans_omp_target): Use correct scoping block.
gcc/testsuite/
PR fortran/95869
* gfortran.dg/gomp/combined-if.f90 (test_target_parallel): Re-enable.
* gfortran.dg/gomp/pr95869.f90: New.
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 67b7094..22f8f96 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -5353,7 +5353,7 @@ gfc_trans_omp_target (gfc_code *code)
pushlevel ();
gfc_start_block (&iblock);
tree inner_clauses
- = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_PARALLEL],
+ = gfc_trans_omp_clauses (&iblock, &clausesa[GFC_OMP_SPLIT_PARALLEL],
code->loc);
stmt = gfc_trans_omp_code (code->block->next, true);
stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
diff --git a/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
index 383086c..bf4a9a8 100644
--- a/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
@@ -18,17 +18,15 @@ contains
end do
end subroutine
- ! TODO: This currently fails with an internal compiler error
- ! (PR 95869)
- !subroutine test_target_parallel
- ! do j = 1, N
- ! !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
- ! do i = 1, N
- ! a(i) = a(i) + 1
- ! end do
- ! !$omp end target parallel
- ! end do
- !end subroutine
+ subroutine test_target_parallel
+ do j = 1, N
+ !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
+ do i = 1, N
+ a(i) = a(i) + 1
+ end do
+ !$omp end target parallel
+ end do
+ end subroutine
subroutine test_target_parallel_loop
do j = 1, N
@@ -105,6 +103,6 @@ contains
end module
-! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 8
"omplower" } }
+! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 9
"omplower" } }
! { dg-final { scan-tree-dump-times "(?n)#pragma omp simd.* if\\(" 7
"omplower" } }
-! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 5
"omplower" } }
+! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 6
"omplower" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr95869.f90
b/gcc/testsuite/gfortran.dg/gomp/pr95869.f90
new file mode 100644
index 0000000..daa8d21
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr95869.f90
@@ -0,0 +1,18 @@
+! PR fortran/95869
+! { dg-do compile }
+
+program pr95869
+ implicit none
+
+ integer, parameter :: N = 100
+ integer, parameter :: LIMIT = 60
+ integer :: i, j
+ integer, dimension(N) :: a = (/ (i, i = 1,N) /)
+ do j = 1, N
+ !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
+ do i = 1, N
+ a(i) = a(i) + 1
+ end do
+ !$omp end target parallel
+ end do
+end program