From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toon Moene To: Jan Hubicka Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org Subject: Re: -freduce-all-givs and fortran Date: Wed, 05 Sep 2001 07:42:00 -0000 Message-id: <3B9639AB.5595BB36@knmi.nl> References: <3B96340B.C1747B6D@knmi.nl> <20010905162832.J10747@atrey.karlin.mff.cuni.cz> X-SW-Source: 2001-09/msg00108.html 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