[patch, fortran, 4.9] Improve efficiency of array constructor operators
Tobias Burnus
burnus@net-b.de
Tue Mar 26 15:35:00 GMT 2013
Thomas Koenig wrote:
> this patch finally makes the idiom
> if (any([a,b,c] < eps)) then
> equivalent to
> if (a<eps .or. b<eps .or. c<eps) then
> so that there is no loss in efficiency through generating
> temporary arrays.
I have not yet looked at the patch, but I wonder whether that causes
invalid code for
if (any([a,b,c] < f()))
by evaluating f() multiple times.
Another question is: Why do we generate a temporary array for ANY/ALL? A
scalar should be sufficient, i.e.
res = .false.
do i = 1, n
res = res .or. (array(i) < eps)
end do
if (res)
In the scalar case with known array size, the middle-end should also be
able to fully unroll the loop.
I do not really see in how far such a patch would replace your patch -
or whether it should be done additionally.
Tobias
More information about the Fortran
mailing list