cmd/compile: compiler/inliner leads to suboptimal register usage #49634
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
What version of Go are you using (
go version
)?and
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have these two methods, where one just wraps the other for type casting. However, the two types are really just aliases:
From a compiler PoV, it seems to me that these two methods should be identical. However, they are not:
It seems that the
GetOp
version makes a less optimal use of the registers: moving the result intoCX
, and then copy the result toAX
. WhereasGetByte
stores the result directly intoAX
and returns it.If I modify the code, to manually inline it:
Then the two outputs become identical:
Tested with
go1.17 linux/amd64
andgo1.17.3 linux/amd64
.I thought this was a strange quirk with the compiler/inliner/optimizer, and possibly worth mentioning here. Feel free to close this issue if it's not relevant.
What did you expect to see?
That the assembly output for the two methods were identical.
What did you see instead?
Less optimal output for the version returning an alias type.
The text was updated successfully, but these errors were encountered: