You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an idea for a compiler optimization to explore. I don't know whether it'll yield worthwhile fruit.
We can generate multiple forms of variadic functions. For example, given:
funcf(s...int) {
// body
}
We could also generate and compile:
funcf.0() {
s:=nil// body
}
funcf.1(xint) {
s:= []int{x}
// body
}
This would shrink call sites. And hopefully the compiler would be able to use the info about s to compile f.0 and f.1 more aggressively. (We might need to add an optimization to remove loops when the loop iteration count is known to be 1.)
There are plenty of open questions. For example: how to decide which variants to generate, whether to rewrite .N suffixes away in backtraces, where to record info about which variants got generated, what the impact is on inlining and escape analysis.
This would also serve as a useful experiment for generics, in that we would need to sort out some questions about how to generate specialized variants of a particular function.
The text was updated successfully, but these errors were encountered:
Potentially related: such an experiment could be extended to specialize functions based on whether the returned values are used or not, or even if the returned values escape the caller or not.
This is an idea for a compiler optimization to explore. I don't know whether it'll yield worthwhile fruit.
We can generate multiple forms of variadic functions. For example, given:
We could also generate and compile:
This would shrink call sites. And hopefully the compiler would be able to use the info about s to compile f.0 and f.1 more aggressively. (We might need to add an optimization to remove loops when the loop iteration count is known to be 1.)
There are plenty of open questions. For example: how to decide which variants to generate, whether to rewrite .N suffixes away in backtraces, where to record info about which variants got generated, what the impact is on inlining and escape analysis.
This would also serve as a useful experiment for generics, in that we would need to sort out some questions about how to generate specialized variants of a particular function.
The text was updated successfully, but these errors were encountered: