$ gfortran-4.3 -O3 -funroll-all-loops -ffast-math foo-2.f90
$ ./a.out
 subroutine with explicit interface and unroll(1):    2.3321450      s
$ gfortran -O3 -funroll-all-loops -ffast-math foo-2.f90
$ ./a.out
 subroutine with explicit interface and unroll(1):    3.0121880      s
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../gcc/trunk/configure --prefix=/home/ig25
--enable-languages=c,fortran --enable-maintainer-mode
Thread model: posix
gcc version 4.4.0 20081122 (experimental) (GCC)

$ cat foo-2.f90
module foo
  implicit none
contains
  subroutine unroll(a,b,c)
    real, dimension(3,3) :: a,b,c
    integer :: i,j
    do i=1,3
       do j=1,3
          c(i,j) = a(i,1)*b(1,j) + a(i,2)*b(2,j) + a(i,3)*b(3,j)
       end do
    end do
  end subroutine unroll
end module foo

program main
  use foo
  implicit none
  integer :: k
  real, dimension(3,3) :: a,b,c, a0, b0
  real :: t1, t2
  character(len=90) :: line

  call random_number(a0)
  call random_number(b0)
  a = a0
  b = b0

  call cpu_time(t1)

  do k=1,10**8
     call unroll(a,b,c)
  end do

  call cpu_time(t2)
  print *,"subroutine with explicit interface and unroll(1): ",t2-t1, " s"
  write (unit=line,fmt='(9G10.3)') c

end program main


-- 
           Summary: [4.4 Regression] speed regression with hand-unrolled
                    matmul
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38434

Reply via email to