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. ..
Created attachment 17371 [details] Fortran file that produce the ICE
Confirmed oni686-apple-darwin9 with gfc -c -fcray-pointer -fexceptions -O2 -ftree-vectorize adw_trajsp.f
Forgot to say that it is a [4.4 Regression].
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
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.
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?
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.
(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.
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.
(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
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
Fixed.