https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66158
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW --- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (In reply to Dominique d'Humieres from comment #1) > Bounds checking is rather cheap. Does the proposed optimization worth the > work? It can be quite significant. An example with recent trunk: ig25@linux-fd1f:~/Krempel/Matmul/Bounds> cat bounds.f90 program main use foo implicit none real, dimension(10,10) :: a, b, c integer :: i call random_number(a) call random_number(b) do i=1,1000000 call my_matmul(a,b,c) end do end program main ig25@linux-fd1f:~/Krempel/Matmul/Bounds> cat foo.f90 module foo implicit none contains subroutine my_matmul(a,b,c) real, dimension(:,:), intent(in) :: a, b real, dimension(:,:), intent(inout) :: c c = matmul(a,b) end subroutine my_matmul end module foo ig25@linux-fd1f:~/Krempel/Matmul/Bounds> gfortran -O3 -fcheck=bounds foo.f90 bounds.f90 && time ./a.out real 0m3.281s user 0m3.277s sys 0m0.002s ig25@linux-fd1f:~/Krempel/Matmul/Bounds> gfortran -O3 foo.f90 bounds.f90 && time ./a.out real 0m1.911s user 0m1.909s sys 0m0.002s