This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -freduce-all-givs and fortran
- To: Richard Henderson <rth at redhat dot com>, Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Subject: Re: -freduce-all-givs and fortran
- From: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- Date: Thu, 06 Sep 2001 16:06:29 -0700
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org, aj at suse dot de, jh at suse dot de
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