Bug 39595 - [4.4/4.5 Regression]ICE in vectorizable_store at tree-vect-transform.c:5361
Summary: [4.4/4.5 Regression]ICE in vectorizable_store at tree-vect-transform.c:5361
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Ira Rosen
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-03-31 08:23 UTC by Peter Knowles
Modified: 2009-04-02 19:19 UTC (History)
3 users (show)

See Also:
Host: i386-apple-darwin8.10.1
Target: i386-apple-darwin8.10.1, x86_64-*-*
Build: i386-apple-darwin8.10.1
Known to work:
Known to fail:
Last reconfirmed: 2009-03-31 12:21:04


Attachments
source and includes that demonstrate the problem (99.65 KB, application/x-gzip)
2009-03-31 08:24 UTC, Peter Knowles
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Knowles 2009-03-31 08:23:56 UTC
$ /usr/local/gfortran/bin/gfortran -c -fno-second-underscore -fdefault-integer-8 -m64 -DMOLPRO -I. -I.. -I../global -O3 dftgrid.f
dftgrid.f: In function 'grid_neighbour_dint':
dftgrid.f:4288: internal compiler error: vector VEC(tree,base) index domain error, in vectorizable_store at tree-vect-transform.c:5358
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ gfortran -v
Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: /tmp/gfortran-20090321/ibin/../gcc/configure --prefix=/usr/local/gfortran --enable-languages=c,fortran --with-gmp=/tmp/gfortran-20090321/gfortran_libs --enable-bootstrap
Thread model: posix
gcc version 4.4.0 20090321 (experimental) [trunk revision 144983] (GCC) 
$ /usr/local/gfortran/bin/gfortran -c -fno-second-underscore -fdefault-integer-8 -m64 -DMOLPRO -I. -I.. -I../global -O2 dftgrid
Comment 1 Peter Knowles 2009-03-31 08:24:40 UTC
Created attachment 17567 [details]
source and includes that demonstrate the problem
Comment 2 Richard Biener 2009-03-31 09:49:03 UTC
Confirmed.
Comment 3 Jakub Jelinek 2009-03-31 12:34:19 UTC
Simplified testcase:
c { dg-do compile }
c { dg-options "-O3" }
      subroutine foo(a,c,i,m)
      double precision a(4,*),b(3,64),c(3,200),d(64)
      integer*8 i,j,k,l,m
      do j=1,m,64
        do k=1,m-j+1
          d(k)=a(4,j-1+k)
          do l=1,3
            b(l,k)=c(l,i)+a(l,j-1+k)
          end do
        end do
        call bar(b,d,i)
      end do
      end
Comment 4 Dominique d'Humieres 2009-03-31 12:51:52 UTC
On i686-apple-darwin9, I need -m64 to get an ICE with the test in comment #3.
Comment 5 H.J. Lu 2009-03-31 16:45:45 UTC
This is triggered by revision 143152:

http://gcc.gnu.org/ml/gcc-cvs/2009-01/msg00163.html
Comment 6 Ira Rosen 2009-04-01 11:21:08 UTC
(In reply to comment #4)
> On i686-apple-darwin9, I need -m64 to get an ICE with the test in comment #3.

And if you change the types?

-      double precision a(4,*),b(3,64),c(3,200),d(64)
+      dimension a(4,*),b(3,64),c(3,200),d(64)

Comment 7 Dominique d'Humieres 2009-04-01 12:11:41 UTC
(In reply to comment #6)
> > On i686-apple-darwin9, I need -m64 to get an ICE with the test in comment #3.
>
> And if you change the types?

[ibook-dhum] f90/bug% gfc -c -O3 pr39595_db.f90
[ibook-dhum] f90/bug% gfc -c -m64 -O3 pr39595_db.f90
pr39595_db.f90: In function 'foo':
pr39595_db.f90:3: internal compiler error: vector VEC(tree,base) index domain error, in vectorizable_store at tree-vect-stmts.c:3038

Comment 8 Dominique d'Humieres 2009-04-01 12:50:20 UTC
On powerpc-apple-darwin9 the code in comment #3 compiles with -m64 -O3, but ICE with the change in comment #6 with:

pr39595_db.f90: In function 'foo':
pr39595_db.f90:3: internal compiler error: vector VEC(tree,base) index domain error, in vectorizable_store at tree-vect-stmts.c:3038

On i686-apple-darwin9 the original code in comment #1 ICE with -O3, but not with -m64 -O3:

[ibook-dhum] bug/dftgrid% gfc -c -m64 -O3 dftgrid.f
[ibook-dhum] bug/dftgrid% gfc -c -O3 dftgrid.f
dftgrid.f: In function 'grid_neighbour_dint':
dftgrid.f:4288: internal compiler error: vector VEC(tree,base) index domain error, in vectorizable_store at tree-vect-stmts.c:3038

Comment 9 Ira Rosen 2009-04-02 10:07:51 UTC
Will the following test do the job? (I added -m64 for target i686-*-*)

! { dg-do compile }
! { dg-options "-c -O3 -fdump-tree-vect-details -m64" { target i686-*-* } }
      subroutine foo(a,c,i,m)
      dimension a(4,*),b(3,64),c(3,200),d(64)
      integer*8 i,j,k,l,m
      do j=1,m,64
        do k=1,m-j+1
          d(k)=a(4,j-1+k)
          do l=1,3
            b(l,k)=c(l,i)+a(l,j-1+k)
          end do
        end do
        call bar(b,d,i)
      end do
      end

! { dg-final { cleanup-tree-dump "vect" } }

Comment 10 Jakub Jelinek 2009-04-02 10:18:01 UTC
No, please don't ever add -m64 or -m32 to dg-options, that is something the tester decides on in how it invokes make check.  If a test is specific to -m64 or -m32, you should be using ilp32 or lp64 etc. effective target requirements,
but in this case there is nothing in the testcase that requires -m64, the test just passes for some targets and fails for others.
Don't add -c, that's implicit for dg-do compile, you're adding it for second time.
Also, I don't like the s/double precision/dimension/ change, the type of the vars should be if possible explicit when you aren't testing the Fortran FE.
On x86_64-linux it fails with double precision, but also real, integer or integer*8 instead of double precision, just don't leave the explicit type out.

The testcase as is in #c3 fails on x86_64-linux and succeeds on i686-linux and
RUNTESTFLAGS=--target_board=unix/-m32 on x86_64-linux, I guess on Darwin similarly, it will fail with RUNTESTFLAGS=--target_board=unix/-m64.
Comment 11 Ira Rosen 2009-04-02 11:16:23 UTC
(In reply to comment #10)
> No, please don't ever add -m64 or -m32 to dg-options, that is something the
> tester decides on in how it invokes make check.  If a test is specific to -m64
> or -m32, you should be using ilp32 or lp64 etc. effective target requirements,
> but in this case there is nothing in the testcase that requires -m64, the test
> just passes for some targets and fails for others.
> Don't add -c, that's implicit for dg-do compile, you're adding it for second
> time.

OK, thanks for the explanation!

> Also, I don't like the s/double precision/dimension/ change, the type of the
> vars should be if possible explicit when you aren't testing the Fortran FE.
> On x86_64-linux it fails with double precision, but also real, integer or
> integer*8 instead of double precision, just don't leave the explicit type out.

I will change it to real then (double does not get vectorized on PowerPC).

> The testcase as is in #c3 fails on x86_64-linux and succeeds on i686-linux and
> RUNTESTFLAGS=--target_board=unix/-m32 on x86_64-linux, I guess on Darwin
> similarly, it will fail with RUNTESTFLAGS=--target_board=unix/-m64.

Here is the final version (the test name will be O3-pr39595.f, so vect.exp will append -O3 to the flags):

! { dg-do compile }
      subroutine foo(a,c,i,m)
      real a(4,*),b(3,64),c(3,200),d(64)
      integer*8 i,j,k,l,m
      do j=1,m,64
        do k=1,m-j+1
          d(k)=a(4,j-1+k)
          do l=1,3
            b(l,k)=c(l,i)+a(l,j-1+k)
          end do
        end do
        call bar(b,d,i)
      end do
      end

! { dg-final { cleanup-tree-dump "vect" } }

Thanks,
Ira


Comment 12 irar 2009-04-02 12:39:41 UTC
Subject: Bug 39595

Author: irar
Date: Thu Apr  2 12:39:28 2009
New Revision: 145445

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145445
Log:

	PR tree-optimization/39595
	* tree-vect-slp.c (vect_build_slp_tree): Check that the size of 
	interleaved loads group is not greater than the SLP group size.


Added:
    trunk/gcc/testsuite/gfortran.dg/vect/O3-pr39595.f
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-slp.c

Comment 13 irar 2009-04-02 18:08:40 UTC
Subject: Bug 39595

Author: irar
Date: Thu Apr  2 18:08:10 2009
New Revision: 145465

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145465
Log:

	PR tree-optimization/39595
	* tree-vect-analyze.c (vect_build_slp_tree): Check that the size of
	interleaved loads group is not greater than the SLP group size.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/vect/O3-pr39595.f
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/tree-vect-analyze.c

Comment 14 Jakub Jelinek 2009-04-02 19:19:32 UTC
Fixed.