This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran: The Road Ahead.
- To: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Subject: Re: Fortran: The Road Ahead.
- From: Joel Sherrill <joel at OARcorp dot com>
- Date: Sun, 7 Dec 1997 10:18:19 -0600 (CST)
- cc: egcs at cygnus dot com
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