-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: inefficient code generation on amd64 #40426
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Comments
/cc @randall77 |
Yes, looks like we need corresponding float support. I have a CL. |
Change https://golang.org/cl/244859 mentions this issue: |
With that CL you should get better code than even 1.14:
Not sure if it would be faster. Please try it and let me know. |
Yes, that CL improve stats:
And compare with go1.14:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Probably, inefficient code generation on amd64.
Probably a slight regression in the performance of the resulting code beetween g.14.6 and master (8696ae8).
Preface
Examining the assembly code listing, I found out that the compiler generates sub-optimal code for some part of the code.
I will not describe the whole journey. I found a code (code from benchmark game) illustrating the problem and will use it for an example.
All source code: https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-go-3.html
Let's pay attention to these lines (60, 61, 62), it's "advance" func:
Let's take a look at the result of the code generation:
We need one instruction to load the value of the left operand and two to calculate the address of the right one.
I rolled back to version go1.14 and found that the codegen there is different. For the same lines, the following code will be generated:
It uses one instruction to load both the left and right side of the expression.
How does it affect code performance?
It depends on how often such a code generation pattern is used in the code and in how hot the pieces of code are.
But we can write benchmark:
Results:
When did the issue start?
git bisect report beetween master(8696ae8) and go1.14:
Issue linked with changes - #36468
/cc @randall77
The text was updated successfully, but these errors were encountered: