-freduce-all-givs and fortran
Toon Moene
moene@knmi.nl
Wed Sep 5 07:42:00 GMT 2001
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
More information about the Gcc
mailing list