-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: optimize single return value type assertion #17405
Comments
cc'ing @randall77 |
I've found that checked scalar type assertions:
are much faster than other type assertions. This commit inlines checked scalar type assertions: 615a52b Before commit benchmarks:
After commit benchmarks:
Can unchecked scalar type assertions ( |
I'll see if I can get in a fix for this before the freeze. |
CL https://golang.org/cl/32416 mentions this issue. |
We used to have to keep on-stack copies of these types. Now they can be registerized. [0]T is kind of trivial but might as well handle it. This change enables another change I'm working on to improve how x.(T) expressions are handled (#17405). This CL helps because now all types that are direct interface types are registerizeable (e.g. [1]*byte). No higher-degree arrays for now because non-constant indexes are hard. Update #17405 Change-Id: I2399940965d17b3969ae66f6fe447a8cefdd6edd Reviewed-on: https://go-review.googlesource.com/32416 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
CL https://golang.org/cl/32313 mentions this issue. |
This is a follow-up for #17118 .
Currently in go tip single return value type assertion is much slower comparing to type assertion returning two values:
Results:
The compiler may optimize single return value type assertion (
x := v.(T)
) by rewriting it into the following code:The text was updated successfully, but these errors were encountered: