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: