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: small struct initialization code is suboptimal because of redundant zeroing #59021
Comments
This is a failure of dead store elimination. It comes about because at that point in compilation, it doesn't realize that the two stores are actually to the same address, because they are different
We could teach DSE that two We could also get rid of the memory dependence of |
Change https://go.dev/cl/578376 mentions this issue: |
What version of Go are you using (
go version
)?Also tested:
go1.21-f5c7416511
,go1.19
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?
https://go.dev/play/p/KYZ1WC9j4VP
https://go.godbolt.org/z/1KMEo5nP8 (note: uses Go 1.19)
What did you expect to see?
Compiler should generate the same code for
new(T)
and&T{}
.What did you see instead?
new(T)
compiles tobut
&T{}
compiles toBig structures like this
are not affected.
The text was updated successfully, but these errors were encountered: