http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53591
Bug #: 53591 Summary: Front-end optimize empty string assignments Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: tkoe...@gcc.gnu.org Based on PR 52861. I think it would be useful to front-end optimize (frontend-passes.c's optimize_assignment, utilizing empty_string()): character(len=5) :: str str = ' ' [That will create a memmove/memcpy followed by a memset.] to either str = '' (RHS length = 0) [This will use a memset] or to str = ' ' (RHS length = LHS length) [That will use an assignment] Currently, the middle-end likes a direct assignment better than a memset, but everything which avoids memmove/memcpy is good. Cf. also trans-expr.c's gfc_trans_string_copy.