cmd/compile: switch statements over constants are not inlined #50253
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
It appears that the inliner runs after constants in if statements are evaluated, which is good, but runs before constants in switch statements are evaluated, which is not good.
This is a problem for switch statements over, say,
runtime.GOOS
orruntime.GOARCH
. Here's an example to reproduce the problem:The switch statement doesn't get inlined, because it's too big, while the if statement does, because it early on reduces to a cost of two.
And confirmed by the assembly listing:
CC @cuonglm @josharian
The text was updated successfully, but these errors were encountered: