What version of Go are you using (go version)?
$ go version
go version devel go1.21-3ed8a1e629 Tue Mar 28 05:41:44 2023 +0000 linux/amd64
Does this issue reproduce with the latest release?
Not on go1.20.2. The generated assembly is in other ways very different to gotip.
What did you do?
https://go.dev/play/p/eKdUtP-irZa
The generated assembly for the Checksum function contains instructions that to my understanding are unnecessary. By removing the []byte return value (like in the Checksum2 function) the generated code for the loop body is what I expected.
What did you expect to see?
The generated assembly for the Checksum function:
...
MOVQ 0x30(AX), DI
BSWAP DI
...
What did you see instead?
There is one occurrence of:
...
MOVQ 0x28(AX), R13
BSWAP R13
vvv
MOVQ 0x30(AX), R15
BSWAP R15
MOVQ R15, DI
^^^
MOVQ 0x38(AX), R15
BSWAP R15
...
My understanding is that the MOVQ first to R15 just to then move it to DI is unnecessary. MOVQ directly to DI is what I expected.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Not on go1.20.2. The generated assembly is in other ways very different to gotip.
What did you do?
https://go.dev/play/p/eKdUtP-irZa
The generated assembly for the Checksum function contains instructions that to my understanding are unnecessary. By removing the []byte return value (like in the Checksum2 function) the generated code for the loop body is what I expected.
What did you expect to see?
The generated assembly for the Checksum function:
What did you see instead?
There is one occurrence of:
My understanding is that the MOVQ first to R15 just to then move it to DI is unnecessary. MOVQ directly to DI is what I expected.