Bug 65597 - ICE in build_outer_var_ref, at omp-low.c:1043
Summary: ICE in build_outer_var_ref, at omp-low.c:1043
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2015-03-27 09:55 UTC by Tobias Burnus
Modified: 2015-06-03 21:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-03-27 00:00:00


Attachments
gcc5-pr65597.patch (905 bytes, patch)
2015-03-30 15:41 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2015-03-27 09:55:13 UTC
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
Comment 1 Dominique d'Humieres 2015-03-27 10:06:40 UTC
Confirmed since at least r210749.
Comment 2 Jakub Jelinek 2015-03-30 13:46:10 UTC
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).
Comment 3 Jakub Jelinek 2015-03-30 15:41:47 UTC
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.
Comment 4 Jakub Jelinek 2015-03-30 17:54:37 UTC
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
Comment 5 Jakub Jelinek 2015-06-03 15:32:18 UTC
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
Comment 6 Jakub Jelinek 2015-06-03 21:44:55 UTC
Fixed.