SpecConstr: -fspec-constr-threshold has likely some undesired behaviour
As the user guide helpfully points out -fspec-constr-threshold
does "Set the size threshold for the SpecConstr transformation."
Currently best I can tell what it does is that if any rhss of a recursive group is larger than threshold
we avoid specializing any of them. I assume to avoid code blowup. So far so good.
But I think we still traverse the AST looking for local bindings to specialize. We don't check the size of local bindings when deciding if we should specialise. So if the top level binding is just a thin (recursive) function over a huge local binding we would still end up specializing the local binding anyway.
As a result using -fspec-constr-threshold
avoid code size blowups is hit and miss.
We also make the decision for the whole recursive group. But if we have some group:
Rec {
f_huge = <huge>
f_2 = <smallish>
f_3 = <smallish>
}
We should still specialize f_2
and f_3
for all call patterns inside the whole group. There is really no good reason not to!