Fortran: The Road Ahead.
Toon Moene
toon@moene.indiv.nluug.nl
Sun Dec 7 10:54:00 GMT 1997
> > III. New loop optimisations.
> >
> > 1. Moving invariant conditionals out of loops.
> Compiler folks often refer to this as unswitching. Note
> that the conditional must be at the top of the loop to
> perform this kind of optimization.
(Sigh). OK, guys, I probably simplified too much. The
optimisation I really had in mind ran something like this:
Transform:
do i = 1, n
<body1>
if (lcond) then
<body2>
else
<body3>
endif
<body4>
enddo
into (variant I):
if (lcond) then
do i = 1, n
<body1>
<body2>
<body4>
enddo
else
do i = 1, n
<body1>
<body3>
<body4>
enddo
endif
or (variant II):
do i = 1, n
<body1>
enddo
if (lcond) then
do i = 1, n
<body2>
enddo
else
do i = 1, n
<body3>
enddo
endif
do i = 1, n
<body4>
enddo
It would be especially interesting to come up with a heuristic to
choose between variant I and variant II, *given the other
transformations I mentioned* :-)
Cheers,
Toon.
More information about the Gcc
mailing list