cmd/compile: code generates unnecessary mov-s #65192
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
Go version
go1.21.6
Output of
go env
in your module/workspace:What did you do?
Compiling the following code leads to assembly that's suboptimal assembly:
The optimization seems to be missing both on arm64 and amd64. I'm currently only showing the output from arm64, because the amd64 is similar.
What did you see happen?
The code gets compiled into this:
What did you expect to see?
I would've expected code more in the lines of:
PS: I just realized that maybe that's happening because it's trying to preserve the register state for returning from the func... if that's the case, the whole logic could happen on registers that don't need to be preserved.
The text was updated successfully, but these errors were encountered: