This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -freduce-all-givs and fortran
- To: Jan Hubicka <jh at suse dot cz>
- Subject: Re: -freduce-all-givs and fortran
- From: Toon Moene <moene at knmi dot nl>
- Date: Wed, 05 Sep 2001 14:41:47 +0000
- CC: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Organization: Royal Netherlands Meteorological Institute
- References: <3B96340B.C1747B6D@knmi.nl> <20010905162832.J10747@atrey.karlin.mff.cuni.cz>
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