Bug 39318 - [4.4 Regression] internal compiler error: verify_stmts failed
Summary: [4.4 Regression] internal compiler error: verify_stmts failed
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-02-27 18:02 UTC by Deji Akingunola
Modified: 2009-03-02 13:38 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-03-01 10:34:19


Attachments
Fortran file that produce the ICE (3.10 KB, application/octet-stream)
2009-02-27 18:03 UTC, Deji Akingunola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Deji Akingunola 2009-02-27 18:02:53 UTC
The attached code produce an ICE (below) with cuurent trunk when the compiler option includes all of '-fno-second-underscore -fexceptions -O3'. The code compiles fine with gfortran-4.3.2.

..
[deji@logos gemclim33]$ gfc -c -m64 -fPIC -fcray-pointer -fconvert=big-endian -fopenmp -fno-second-underscore -fexceptions -O3 adw_trajsp.f
adw_trajsp.f: In function ‘adw_trajsp_.omp_fn.0’:
adw_trajsp.f:459: error: Dead STMT in EH table
D.3244_455 = __builtin_sqrtf (D.3243_454);

adw_trajsp.f:459: internal compiler error: verify_stmts failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
..
Comment 1 Deji Akingunola 2009-02-27 18:03:42 UTC
Created attachment 17371 [details]
Fortran file that produce the ICE
Comment 2 Dominique d'Humieres 2009-02-27 18:24:55 UTC
Confirmed oni686-apple-darwin9 with

gfc -c -fcray-pointer -fexceptions -O2 -ftree-vectorize adw_trajsp.f
Comment 3 Dominique d'Humieres 2009-02-27 19:03:05 UTC
Forgot to say that it is a [4.4 Regression].
Comment 4 Dominique d'Humieres 2009-02-27 19:59:25 UTC
Reduced test:

      subroutine adw_trajsp ( F_lon, F_lat, F_x, F_y, F_z,
     %                        F_u, F_v, F_dt,i0,in,j0,jn)
      implicit none
      real F_lon(*),F_lat(*),F_x(*),F_y(*),F_z(*),F_u(*),F_v(*),F_dt
      integer i0,in,j0,jn
      integer n, ij, nij,vnij, i,j,k
      real*8 xsin(i0:in,j0:jn)
!$omp parallel do private(xsin)
         do j=j0,jn
         do i=i0,in
            xsin(i,j) = sqrt( F_u(n) ** 2 + F_v(n) ** 2 ) * F_dt
         end do
         end do
!$omp end parallel do
      return
      end

ibook-dhum] f90/bug% gfc -c -fopenmp -fexceptions -O2 -ftree-vectorize adw_trajsp_red.f
adw_trajsp_red.f: In function 'adw_trajsp_.omp_fn.0':
adw_trajsp_red.f:8: error: Dead STMT in EH table
D.1679_46 = __builtin_sqrtf (D.1678_45);

adw_trajsp_red.f:8: internal compiler error: verify_stmts failed
Comment 5 Dominique d'Humieres 2009-02-28 11:17:57 UTC
The compilation flags in comment #2 should be 

gfc -c -fopenmp -fcray-pointer -fexceptions -O2 -ftree-vectorize adw_trajsp.f

in order to get the ICE. The code compiles without -fopenmp.

The code compiles with the flags in comments #0 or with "-c -fopenmp -fcray-pointer -fexceptions -O2 -ftree-vectorize" on powerpc-apple-darwin9.
Comment 6 Ira Rosen 2009-03-01 10:34:18 UTC
Reduced it a bit more:

      subroutine adw_trajsp (F_u,i0,in,j0,jn)
      implicit none
      real F_u(*)
      integer i0,in,j0,jn
      integer n,i,j
      real*8 xsin(i0:in,j0:jn)
!$omp parallel do private(xsin)
         do j=j0,jn
         do i=i0,in
            xsin(i,j) = sqrt(F_u(n))
         end do
         end do
!$omp end parallel do
      return
      end

on x86_64-suse-linux with 
gfortran -c -fopenmp -fcray-pointer -fexceptions   -O2 -ftree-vectorize.

When we vectorize a function call, we replace the RHS of the stmt with "something harmless": D.1692_41 = __builtin_sqrtf (pretmp.45_79); is replaced with D.1692_41 = 0.0;. We don't remove the original stmt from the EH table. The question is it OK to vectorize function that are in EH table?

Comment 7 rguenther@suse.de 2009-03-01 10:58:22 UTC
Subject: Re:  internal compiler error: verify_stmts
 failed

On Sun, 1 Mar 2009, irar at il dot ibm dot com wrote:

> ------- Comment #6 from irar at il dot ibm dot com  2009-03-01 10:34 -------
> Reduced it a bit more:
> 
>       subroutine adw_trajsp (F_u,i0,in,j0,jn)
>       implicit none
>       real F_u(*)
>       integer i0,in,j0,jn
>       integer n,i,j
>       real*8 xsin(i0:in,j0:jn)
> !$omp parallel do private(xsin)
>          do j=j0,jn
>          do i=i0,in
>             xsin(i,j) = sqrt(F_u(n))
>          end do
>          end do
> !$omp end parallel do
>       return
>       end
> 
> on x86_64-suse-linux with 
> gfortran -c -fopenmp -fcray-pointer -fexceptions   -O2 -ftree-vectorize.
> 
> When we vectorize a function call, we replace the RHS of the stmt with
> "something harmless": D.1692_41 = __builtin_sqrtf (pretmp.45_79); is replaced
> with D.1692_41 = 0.0;. We don't remove the original stmt from the EH table. The
> question is it OK to vectorize function that are in EH table?

Well, we should transfer the EH region information to the vectorized
statement in this case.  Which might be tricky ... do we have a link
to the original statement when producing the new one?

Richard.
Comment 8 Ira Rosen 2009-03-01 11:15:11 UTC
(In reply to comment #7)
> > question is it OK to vectorize function that are in EH table?
> Well, we should transfer the EH region information to the vectorized
> statement in this case.  Which might be tricky ... do we have a link
> to the original statement when producing the new one?

We have the original scalar stmt (gimple).

Thanks,
Ira

> Richard.

Comment 9 rguenther@suse.de 2009-03-01 11:32:05 UTC
Subject: Re:  internal compiler error: verify_stmts
 failed

On Sun, 1 Mar 2009, irar at il dot ibm dot com wrote:

> ------- Comment #8 from irar at il dot ibm dot com  2009-03-01 11:15 -------
> (In reply to comment #7)
> > > question is it OK to vectorize function that are in EH table?
> > Well, we should transfer the EH region information to the vectorized
> > statement in this case.  Which might be tricky ... do we have a link
> > to the original statement when producing the new one?
> 
> We have the original scalar stmt (gimple).

Ok.  Then

  if (maybe_clean_or_replace_eh_stmt (old_stmt, new_stmt))
    gimple_purge_dead_eh_edges (bb);

should be enough to fix this.

Richard.
Comment 10 Ira Rosen 2009-03-01 12:27:13 UTC
(In reply to comment #9)
> Ok.  Then
>   if (maybe_clean_or_replace_eh_stmt (old_stmt, new_stmt))
>     gimple_purge_dead_eh_edges (bb);
> should be enough to fix this.
> Richard.

Yes, it fixes the ICE. Thanks! I'll submit a patch after testing.

Thanks,
Ira

Comment 11 irar 2009-03-02 11:52:26 UTC
Subject: Bug 39318

Author: irar
Date: Mon Mar  2 11:52:15 2009
New Revision: 144541

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144541
Log:
2009-03-02  Richard Guenther  <rguenther@suse.de>
            Ira Rosen  <irar@il.ibm.com>

	PR tree-optimization/39318
	* tree-vect-transform.c (vectorizable_call): Transfer the EH region
	information to the vectorized statement.


Added:
    trunk/gcc/testsuite/gfortran.dg/vect/pr39318.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-transform.c

Comment 12 Richard Biener 2009-03-02 13:38:41 UTC
Fixed.