You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The register allocator is trying and failing to keep DI unoccupied because it thinks it needs it for the return value (the uint16 one).
I think the priorities are just wrong. Saving the register may help later. Moving the value definitely costs now.
We avoid allocating registers when we know they may have a fixed use
later (arg/return value, or the CX shift argument to SHRQ, etc.) But
it isn't worth avoiding that register if it requires moving another
register.
A move we may have to do later is not worth a move we definitely have
to do now.
Fixesgolang#59288
Change-Id: Ibbdcbaea9caee0c5f3e0d6956a1a084ba89757a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/479895
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
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.
The text was updated successfully, but these errors were encountered: