GNU Fortran 95 (GCC 4.1.0 20050715 (experimental)), when run with the options -Wall -O3 -march=pentium4 -S, optimises one of the two calls to the sin intrinsic away in the following function: function optsin (x) implicit none double precision :: optsin double precision, intent(in) :: x optsin = sin(x) / (1 + sin(x)) end function optsin In the "equivalent" function function optmatmul (a, b, ni, nj) implicit none integer, intent(in) :: ni, nj double precision :: optmatmul(ni, nj) double precision, intent(in) :: a(ni, nj), b(ni, nj) optmatmul = matmul(a, b) / (1 + matmul(a, b)) end function optmatmul the two calls to matmul both remain present in the assembler output, although they are known to return the same result.
-- Summary: Double occurrence of matmul intrinsic not optimised Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: schnetter at aei dot mpg dot de CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22572