identified bug in g77 on Alpha

Craig Burley burley@gnu.org
Tue May 19 15:14:00 GMT 1998


>You will find below the assembly code of a simple Fortran routine which
>crashes with segmentation fault when storing the first element 
>      in( jT_f-hd_T     ) = Xsp
>whereas everything is fine when commenting this line.
>
>The assembly code (generated with 
>-ffast-math -fexpensive-optimizations -fomit-frame-pointer -fno-inline
>or with -O5)
>uses a zapnot instruction to copy an address.
>BUT the zapnot parameter is 15 (copuing 4 bytes) instead of 255 (to copy
>8 bytes). 
>
>I guess this is typically a 64 bit issue. As, from my understanding,
>zapnots are used a lot to copy registers, this may create problems
>elsewhere.

Thanks for reporting this.  I've looked into it, and it seems to
me that the compiler is doing the "right thing", though maybe not
the best thing.

In essence, what it is doing is performing the computations involving
jT_f, hd_T, and so on within the types of those variables -- specifically,
within the INTEGER type, which is 32 bits on Alphas.

I don't have the latest egcs snapshot(s) built on my Alpha, so I can't
check whether egcs will do better at this.  There is motivation to
do so; by doing the computations in the 64-bit "native" type of
the Alpha, faster code can be produced, from what I understand.

In the meantime, you might look into whether explicitly declaring
the relevant index variables as INTEGER*8.

Also, it is difficult to tell why the code is a problem for you,
since you sent only the subroutine.  Looks to me as if the code
would work fine for small (less than 32-bit-wide) values of the
relevant index variables, since the assembly code you identify
as problematic seems to involve only those INTEGER variables, not
any computed pointer variables.

So, if you want to submit a new bug report on a problem like this,
it might be a good idea to include a main program unit that
sets up the appropriate values in the COMMON area and then calls
the subroutine as needed to trigger the bug.

        tq vm, (burley)

P.S. Here is the code you originally submitted:

      subroutine simul_trace( in, Xsp, Ysp, Xrcv, Yrcv )

      common /Idim/ jT_f, jT_l, nT, nT_dim
      common /Idim/ jZ_f, jZ_l, nZ, nZ_dim
      common /Idim/ jZ2_f, jZ2_l, nZ2, nZ2_dim
      common /Idim/ jzs_f, jzs_l, nzs, nzs_dim, l_amp
      common /Idim/ hd_S, hd_Z, hd_T
      common /Idim/ nlay, nlayz
      common /Idim/ n_work
      common /Idim/ nb_calls
	
      real     Xsp, Ysp, Xrcv, Yrcv
      real     in( jT_f-hd_T : jT_l )
	
      in( jT_f-hd_T     ) = Xsp
      in( jT_f-hd_T + 1 ) = Ysp 
      in( jT_f-hd_T + 2 ) = Xrcv
      in( jT_f-hd_T + 3 ) = Yrcv
      end



More information about the Gcc-bugs mailing list