-freduce-all-givs and fortran
Dan Nicolaescu
dann@godzilla.ICS.UCI.EDU
Thu Sep 6 16:06:00 GMT 2001
How about the following code?
It shows another issue that occurs in swim from SPEC
(for the people that have access to SPEC, look at subroutine calc1)
SUBROUTINE TEST
PARAMETER(N=100,M=113)
COMMON /COM/ A(N,M), B(N,M), C(N,M), D(N,M)
DO I = 1, N
DO J = 1, M
A(I,J) = B(I+1,J) + C(I,J)
D(I,J) = B(I+1,J) + C(I,J)
ENDDO
ENDDO
END
SUBROUTINE TEST2
PARAMETER(N=100,M=113)
COMMON /COM/ A(N,M), B(N,M), C(N,M), D(N,M)
DO I = 1, N
DO J = 1, M
A(I,J) = B(I,J) + C(I,J)
D(I,J) = B(I,J) + C(I,J)
ENDDO
ENDDO
END
The innner loop for both functions as compiled by 3.0 -O2 on SPARC:
In the first subroutine:
.LL9:
ld [%i5], %f2
addcc %g1, -1, %g1
ld [%i2], %f3
add %i5, 400, %i5
fadds %f3, %f2, %f3
st %f3, [%i4] <- after this store
ld [%i2], %f4 <- this is reloaded
add %i4, 400, %i4
fadds %f4, %f2, %f4
add %i2, 400, %i2
st %f4, [%i3]
bpos .LL9
add %i3, 400, %i3
In the second one everything is fine:
.LL22:
ld [%i5], %f2
addcc %g1, -1, %g1
ld [%i4], %f3
add %i5, 400, %i5
fadds %f2, %f3, %f2
add %i4, 400, %i4
st %f2, [%i3]
st %f2, [%i2]
add %i2, 400, %i2
bpos .LL22
add %i3, 400, %i3
More information about the Gcc-patches
mailing list