This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH to hoist loads/stores out of loops


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]