This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52861] New: (missed optimisation) missed transformation to memset with -O3
- From: "arnaud02 at users dot sourceforge.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 04 Apr 2012 09:25:01 +0000
- Subject: [Bug fortran/52861] New: (missed optimisation) missed transformation to memset with -O3
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52861
Bug #: 52861
Summary: (missed optimisation) missed transformation to memset
with -O3
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: arnaud02@users.sourceforge.net
This is a minor missed-optimisation noticed as follow up to PR52835.
This is not a regression.
>cat qq1.f
SUBROUTINE QQ2( ISU, ZSPM, RSV, MS )
INTEGER :: ISU(MS)
CHARACTER(8) :: ZSPM(MS)
REAL :: RSV(MS)
DO IS=1,MS
ISU(IS)=0
ZSPM(IS)=' '
RSV(IS) =0.0
ENDDO
END subroutine qq2
>cat qq2.f
SUBROUTINE QQ2( ISU, ZSPM, RSV, MS )
INTEGER :: ISU(MS)
CHARACTER(8) :: ZSPM(MS)
REAL :: RSV(MS)
DO IS=1,MS
ISU(IS)=0
RSV(IS) =0.0
ENDDO
DO IS=1,MS
ZSPM(IS)=' '
ENDDO
END subroutine qq2
>gfortran470 -O3 -c qq1.f ; gfortran470 -O3 -c qq2.f
>nm qq1.o qq2.o
qq1.o:
0000000000000000 T qq2_
qq2.o:
U memset
0000000000000000 T qq2_
The compiler has not be able to transform the assignments to ISU and RSV as
calls to memset when the loop contains an assignment to a CHARACTER variable.
This suggests that the dependency generator can be improved or that the Fortran
front-end could pass a better representation to the middle-end.
Additionally, it should be possible to transform
DO IS=1,MS
ZSPM(IS)=' '
ENDDO
as a call to memset. gcc 4.7.0 cannot:
>cat qq3.f
SUBROUTINE QQ2( ZSPM, MS )
CHARACTER(8) :: ZSPM(MS)
DO IS=1,MS
ZSPM(IS)=' '
ENDDO
END subroutine qq2
>/usr/local/gcc/gfortran470 -O3 -c qq3.f
>nm qq3
qq3.f qq3.o
>nm qq3.o
0000000000000000 T qq2_