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: improve DCE when inlining empty functions #21440
Comments
Also related, issue #13095. It also requires the ability to get rid of autotmps that are assigned to but are otherwise unused. |
It would be great to be able to disable features with empty functions! Please keep in mind that for a scenario as described in #21424 the statement given by @griesemer is really necessary because it allows me to depend on this functionality (in that specific case to define the scope of support to constant expressions, assert that this is the idiomatic way to solve the problem and guarantee future support). |
This is fixed by CL 38746. @josharian We still do emit the go.string."abc" symbol. Maybe open a different issue for that. |
Change https://golang.org/cl/58732 mentions this issue: |
Implement int reg <-> fp reg moves on amd64. If we see a load to int reg followed by an int->fp move, then we can just load to the fp reg instead. Same for stores. math.Abs is now: MOVQ "".x+8(SP), AX SHLQ $1, AX SHRQ $1, AX MOVQ AX, "".~r1+16(SP) math.Copysign is now: MOVQ "".x+8(SP), AX SHLQ $1, AX SHRQ $1, AX MOVQ "".y+16(SP), CX SHRQ $63, CX SHLQ $63, CX ORQ CX, AX MOVQ AX, "".~r2+24(SP) math.Float64bits is now: MOVSD "".x+8(SP), X0 MOVSD X0, "".~r1+16(SP) (it would be nicer to use a non-SSE reg for this, nothing is perfect) And due to the fix for #21440, the inlined version of these improve as well. name old time/op new time/op delta Abs 1.38ns ± 5% 0.89ns ±10% -35.54% (p=0.000 n=10+10) Copysign 1.56ns ± 7% 1.35ns ± 6% -13.77% (p=0.000 n=9+10) Fixes #13095 Change-Id: Ibd7f2792412a6668608780b0688a77062e1f1499 Reviewed-on: https://go-review.googlesource.com/58732 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
g
compiles to:It should compile to nothing. In general, when inlining an empty function, all that should remain is evaluating its arguments for side-effects.
Related but slightly different: Replace the body of g with
f("abc")
. Theng
compiles to nothing, but we still emit a vestigial"abc"
string symbol.This kind of code commonly shows up as a result of disabling features with build tags. See #21424.
cc @gstupp
The text was updated successfully, but these errors were encountered: