Fortran: The Road Ahead.
Joel Sherrill
joel@OARcorp.com
Sun Dec 7 08:18:00 GMT 1997
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
More information about the Gcc
mailing list