cmd/compile: inlining of range funcs should be more aggressive #69885
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
Consider the following program:
Building it with
GOEXPERIMENT=newinliner
withgo1.24-cbdb3545ad
reports:Note that despite the utter trivialness of the loop body (
consumer-range1
), it cannot be inlined.I think that inlining of range bodies deserves a special case and that the cost of the synthetic function is unimportant. If this were a "normal" loop, the body would inherently be part of the
consumer
function, no matter how complex it'd be. If we know thatyield
is only called in a single place syntactically, then we should be able to unconditionally inline the range func and produce code no more complex than for a normal loop (excluding the state tracking for range funcs, but that's fixed overhead).I'm sure I'm missing something.
(The bot will find many related issues, but I don't think any of them directly mention this general case.)
The text was updated successfully, but these errors were encountered: