The return value of this function is known at compile time, but from looking at
dump-tree-optimized this seems not to be optimized as such.

INTEGER FUNCTION F1()
  INTEGER :: I1
  INTEGER, TARGET :: I2
  INTEGER, POINTER :: IP

  INTERFACE
    SUBROUTINE S(I1,I2)
      INTEGER,INTENT(IN) :: I1
      INTEGER, POINTER :: IP
    END SUBROUTINE S
  END INTERFACE

  I1=1
  I2=1
  IP=>I2
  CALL S(I1,IP)
  IP=2

  F1=I1
END FUNCTION F1

F1=1 can be infered from the fact that it is an intent(in) argument of S (so
the value cant be changed within S), and the fact that I1 does not have the
target attributed, so can not be 'aliased' with the pointer IP.


-- 
           Summary: fortran rules for optimizing
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


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

Reply via email to