The compiler should be able to detect that s and c are not aliased, so a call to memcpy instead of memmove could be issued.
$ cat memmove.f90 program main character(len=1) :: s character(len=2) :: c s = 'a' c = repeat(s,2) end program main $ gfortran -fdump-tree-original memmove.f90 $ cat memmove.f90.003t.original MAIN__ () { char c[1:2]; char s[1:1]; _gfortran_set_std (70, 127, 0); s[1]{lb: 1 sz: 1} = "a"[1]{lb: 1 sz: 1}; { char str.0[2]; _gfortran_string_repeat ((char[1:] *) &str.0, 1, &s, 2); __builtin_memmove (&c, (char[1:] *) &str.0, 2); } } -- Summary: memmove for string operations Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30398