-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: double zeroing and unnecessary copying/stack use #67957
Comments
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Hmm, I do not get the same generated code as you do. At 722d594, right? Could you double-check the code you pasted and the Go stdlib git commit hash? |
I've double-checked (and rebuild). I'm definitely on 722d594, with a clean working directory. And I can reproduce it by downloading the code I shared. I've also tried with a newer master, ca5ba14, and am getting the same output. GODEBUG, GOEXPERIMENT, and GOAMD64 are all unset.
|
Ah, for some reason |
Passing |
Ok, a bunch of things here.
This code makes a temporary The reason this happens is that we have rules (starting at I don't see anything obvious to fix for number 4. We could change the constant, sure, but the rule description says, and I mostly agree, that we don't want to do this for arbitrary sized objects because we'd end up having to spill/restore all its individual components anyway. |
Change https://go.dev/cl/592596 mentions this issue: |
Change https://go.dev/cl/592615 mentions this issue: |
Regarding 4 and "we'd end up having to spill/restore all its individual components anyway", maybe the count of stores shouldn't include constants being stored? |
@dominikh Sure, that would be an improvement. Maybe difficult to do though given how the rules are currently structured. |
x86 is better at storing constant ints than constant floats. (It uses a constant directly in the instruction stream, instead of loading it from a constant global memory.) Noticed as part of #67957 Change-Id: I9b7b586ad8e0fe9ce245324f020e9526f82b209d Reviewed-on: https://go-review.googlesource.com/c/go/+/592596 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Go version
go version devel go1.23-722d59436b Thu May 16 02:00:26 2024 +0000 linux/amd64
Output of
go env
in your module/workspace:What did you do?
go build -gcflags=-S
the code at https://play.golang.org/p/tt0T6oOsQvr.go and look at the assembly generated formain
What did you see happen?
What did you expect to see?
At a minimum, we shouldn't zero the same memory twice. Ideally, we'd zero
Sink
and store constants to it, not using any stack./cc @golang/compiler
The text was updated successfully, but these errors were encountered: