The following Fortran program causes an ICE with -fopenmp; it doesn't with -fopenmp-simd nor does the equivalent C program ICE: !$omp do simd collapse(1) ^ internal compiler error: in build_outer_var_ref, at omp-low.c:1206 0xaa0d0c build_outer_var_ref ../../gcc/omp-low.c:1206 0xaae1d1 lower_rec_input_clauses ../../gcc/omp-low.c:3959 0xab1c8a lower_omp_for ../../gcc/omp-low.c:10622 external foo !$omp do simd collapse(1) do i = 1, 151, 31 call foo(); end do end
Confirmed since at least r210749.
void bar (int, int); int foo (void) { int i, j; i = 5; j = 8; #pragma omp for simd linear(j:31) for (i = 0; i < 151; i += 31) { bar (i, j); j += 31; } return i + j; } ICEs though. I've just raised a question about this on omp-lang, whether this is valid or not is fuzzy (both in 4.0 and in TR3). Maybe both the Fortran testcase and this one is invalid, maybe just this one and not the Fortran one, maybe both are valid, but it is unclear what they should do. There is also a clear bug on the Fortran FE side: #pragma omp simd linear(count.0:31) linear(i:31) collapse(1) for (count.0 = 0; count.0 < 5; count.0 = count.0 + 1) is clearly wrong, count.0 should have linear(count.0:1).
Created attachment 35184 [details] gcc5-pr65597.patch That said, IMHO this patch is a step in the right direction and fixes this Fortran testcase, though the C testcase as well as similar Fortran testcase with a different var under linear clause still ICEs.
Author: jakub Date: Mon Mar 30 17:54:05 2015 New Revision: 221776 URL: https://gcc.gnu.org/viewcvs?rev=221776&root=gcc&view=rev Log: PR fortran/65597 * trans-openmp.c (gfc_trans_omp_do): For !simple simd with explicit linear clause for the iterator set OMP_CLAUSE_LINEAR_NO_COPYIN. For implcitly added !simple OMP_CLAUSE_LINEAR set it too. Use step 1 instead of the original step on the new iterator - count. * testsuite/libgomp.fortran/pr65597.f90: New test. Added: trunk/libgomp/testsuite/libgomp.fortran/pr65597.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-openmp.c trunk/libgomp/ChangeLog
Author: jakub Date: Wed Jun 3 15:31:46 2015 New Revision: 224090 URL: https://gcc.gnu.org/viewcvs?rev=224090&root=gcc&view=rev Log: Backported from mainline 2015-03-30 Jakub Jelinek <jakub@redhat.com> PR fortran/65597 * trans-openmp.c (gfc_trans_omp_do): For !simple simd with explicit linear clause for the iterator set OMP_CLAUSE_LINEAR_NO_COPYIN. For implcitly added !simple OMP_CLAUSE_LINEAR set it too. Use step 1 instead of the original step on the new iterator - count. * testsuite/libgomp.fortran/pr65597.f90: New test. Added: branches/gcc-4_9-branch/libgomp/testsuite/libgomp.fortran/pr65597.f90 Modified: branches/gcc-4_9-branch/gcc/fortran/ChangeLog branches/gcc-4_9-branch/gcc/fortran/trans-openmp.c branches/gcc-4_9-branch/libgomp/ChangeLog
Fixed.