SpecConstr processes bindings in a different order between 9.4 and 9.6
While looking into #22893 (comment 479506) @mpickering and me realized that some functions were not getting specialized by SpecConstr in 9.6 which were in 9.4
Increasing the limit -fspec-constr-count
made these differences disappear.
To the best of my understanding this is because 565a8ec8 (initially in !8135 (closed)) changes the order in which bindings are processed.
This means if we have a typical setup with code like:
benchmarks = [bench f1, bench f2, bench f3, bench f4]
Then between 9.4 and 9.6 one version will specialise the first 3 appearances of bench
to their arguments, and the other will specialise the last three.
I believe this is due to changes around the order in which bindings are processed inside specConstrProgram
/scTopBinds
!8135 (diffs) but I have yet to verify that.
I believe the order in which bindinds are proccessed in 9.4 and before was initially implemented in 8a588511 which alludes to the order mattering for compile times.
If it's little work we should consider moving back to the same order of considering specializations that we used in 9.4 for SpecConstr just to avoid "random" performance differences in users code.