Sometimes the codegen emits a COPY with overlapping registers, such as
this one:
$r25r24 = COPY $r24r23
Our current expansion of such COPY would be wrong, since it'd start
with the lower register first, with the second mov assuming the
registers are not modified in-between:
mov r24, r23 mov r25, r24
(i.e. that's effectively mov r25, r23, which is _ayy ayy bad_.)
This patch improves the expansion by making it detect whether the
registers are overlapping and if so, expanding from the high register
first:
mov r25, r24 mov r24, r23
Because our registers are always paired in descending order (e.g.
there's r25r24, but no r24r25), I think it'd be safe to go with the
high-to-low expansion always (not only if the registers overlap), but
that makes the output a bit more difficult to follow and would require
adjusting the existing tests -- so I went with the more safer & simpler
route.
In the wild, this was found here:
https://github.com/rust-lang/rust/issues/98167.
Using name CopyHasOverlappingRegs maybe confusing, for the case DestHi == SrcLow. Though there is overlapping for r25r24 -> r24r23, we have to still copy lower byte first.
So I suggest
And the long comment is unnecessary, since the logic is clear enough to understand.