https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92698
--- Comment #2 from mjr19 at cam dot ac.uk --- Thomas is quite correct that I had failed to mark the array as contiguous, at which point the double copy is more reasonable (although memcpy will also expect its arguments to be contiguous). He also correctly points out that a(n:n+len-1) = a(n+1:n+len) will optimise to memmove if a is known to be contiguous. However, I still think there is scope for further improvement. a(n:n+len-1) = a(n+offset:n+offset+len-1) never seems to optimise, whether or not a is contiguous, presumably because the sign of offset is unknown. However, as memmove copes with either sign of offset (or offset=0), concerns about the value of offset seem unnecessary. Also, I suspect that arrays in Fortran are often contiguous, even when this is not explicitly stated, so introducing a special case for contiguous arrays at high optimisation levels may be beneficial. The explicit "contiguous" attribute was introduced only in F2008 (and does not require packing and unpacking by the caller if the caller's array is already contiguous). I expect a lot of code has not progressed further than F2003. The example I offered was not real code. The real code in which this arose was a Fortran implementation of Timsort in which the assignment was just one part of a subroutine, albeit a significant part in terms of execution time.