This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: -freduce-all-givs and fortran


Jan Hubicka wrote:

> Can you please show me simple testcase?  It probably makes sense to
> reorganize loop optimizer - I am thinking about separating BIV/GIV
> discovery code to separate library, as it has more usage than just
> strength reducing and loop unrolling and then we can think about
> larger changes in this area.

Here's an example:

      SUBROUTINE SUB(A, B, C, D, N, M)
      INTEGER N, M
      REAL A(N, M), B(N, M), C(N, M), D(N, M)
      DO J = 1, M
         DO I = 1, N
            A(I, J) = B(I, J) + C(I, J) * D(I, J)
         ENDDO
      ENDDO
      END

If you do not reduce any givs, you need 7 integer registers in the inner
loop: one for A, B, C, D, I, J and N (because addr(A(I,J)) = addr(A) + I
- 1 + (J - 1) * N, etc.)

If you reduce all givs *and* move all loop invariants, you'll only need
5 registers: one for A, B, C, D and I.  This is also the minimum.

[ This analysis is slightly simplified w.r.t. the real result
  when you compile this with g77, because I is *not* the loop
  count in the g77-compiled assembler ]

The difference will get larger for higher-rank arrays.

Hope this helps,

--
Toon Moene, KNMI, PO Box 201, 3730 AE De Bilt, The Netherlands.
Tel. +31302206443, Fax +31302210407,  e-mail moene@knmi.nl
URL: http://www.knmi.nl/hirlam


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]