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: Fortran: The Road Ahead.




On Sun, 7 Dec 1997, Toon Moene wrote:

> III. New loop optimisations.
> 
>     1. Moving invariant conditionals out of loops.
> 
>       Transforms:
> 
>       do i = 1, n
>          if (lcond) then
>             <body1>
>          else
>             <body2>
>          endif
>       enddo
> 
>       into:
> 
>       if (lcond) then
>          do i = 1, n
>             <body1>
>          enddo
>       else
>          do i = 1, n
>             <body2>
>          enddo
>       endif
> 
>       Probably only interesting if lcond is expensive to (re-)calculate.

My gut feeling is that you may be underestimating the value of moving
the evaluation of lcond out of the loop.  lcond is going to evaluated n
times.  That makes the cost of leaving the evaluation in the loop quite a
bit higher.

Plus, if lcond if inexpensive then the values are in registers which
increases the pressure on registers. 

Overall, this seems to be more valuable an optimization than you are
giving it credit for.  

--joel
Joel Sherrill                    Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (205) 722-9985





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