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: Multiple cse and loop opts


Michael Hayes wrote:
> 
> Joern Rennecke writes:
>  > > Exactly.  I "invented" the second pass through loop because it can't
>  > > handle GIVs of the form (INVARIANT * BIV + INVARIANT + CONSTANT), which
>  > > are ubiquitous in Fortran-generated code because Fortran array indices
>  > > start at 1, not 0.
>  >
>  > The second pass is also useful when an inner loop has been completely
>  > unrolled, and/or an inner loop has been optimized leaving some dead
>  > code around.
> 
> However, loop unrolling currently only occurs on the last pass.

Yes, this is (or rather: was) intentional.  The reason for it was that,
prior to rth's excellent giv-combining work, running loop unrolling in
the first loop pass would mean creating n times as many givs (needing n
times as many registers) as was necessary (n the unroll factor).

I.e.

      DO I = 1, N
         Y(I) = X(I)
      ENDDO

has two givs (in the final analysis - there might be intermediaries).

Without giv-combining

      DO I = 1, N, 4
         Y(I  ) = X(I  )
         Y(I+1) = X(I+1)
         Y(I+2) = X(I+2)
         Y(I+3) = X(I+3)
      ENDDO

has eight givs which will lead the second pass through loop to reduce
them and use up eight registers in the process.

-- 
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: fortran@gnu.org; egcs: egcs-bugs@cygnus.com


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