PATCH to hoist loads/stores out of loops
Toon Moene
toon@moene.indiv.nluug.nl
Mon Jul 20 13:16:00 GMT 1998
Wow !
This is great stuff; this is a long standing optimisation request
from the Fortran community :-)
[ This is beyond my wildest dreams of the possible outcomes of
the egcs project - having a C++ guru solving Fortran optimi-
sation shortcomings :-) :-) ]
For instance:
subroutine sdotsub(s, x, y, n)
dimension x(n), y(n)
s = 0.0
do i = 1, n
s = s + x(i) * y(i)
enddo
end
Now gets (w.r.t. the original):
L5:
fmoves a0@+,fp0
- fsglmuls a2@+,fp0
- fadds a1@,fp0
- fmoves fp0,a1@
+ fsglmuls a1@+,fp0
+ faddx fp0,fp1
dbra d0,L5
Could you also pull the same trick for the following code:
subroutine gemm(a, b, c, m, n, k)
integer i,m,n,k,l,j
dimension a(k,m), b(n,k), c(n,m)
do i=1,m ! poor for illustration only
do j=1,n
do l=1,k
c(j,i) = c(j,i) + a(l,i)*b(j,l)
end do
end do
end do
end
Note how the address of the c(j,i) element is constant in the inner
loop (this is Fortran idiom that's a lot more common than the
sdotsub example above).
Thanks in advance,
Toon.
"Besides, the determined Real Programmer can write Fortran in any
language".
More information about the Gcc-patches
mailing list