https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82918
--- Comment #2 from Antony Polukhin <antoshkka at gmail dot com> --- The example from above now produces optimal assembly on GCC-9 (trunk). However, swapping first two lines still produces suboptimal result: struct array { int data[3]; }; void foo2(array& value, const array& value2) { if (&value == &value2) return; value.data[1] = value2.data[0]; value.data[0] = value2.data[0]; value.data[2] = value2.data[0]; } Outputs: _Z4foo2R5arrayRKS_: cmp rdi, rsi je .L1 mov eax, DWORD PTR [rsi] mov DWORD PTR [rdi+4], eax mov DWORD PTR [rdi], eax mov eax, DWORD PTR [rsi] <=== This is not required mov DWORD PTR [rdi+8], eax .L1: ret