SpecConstr: Denest local, non-recursive lets
Suppose we see (local or at top-level)
f xs = let binds in g as;
rest
where
-
bindsbindsg -
xsdon't occur inbindsand -
asdo not mentionbinds. In this situation it might be interesting to specialisefandgfor call patterns inrest, but it is difficult to do it in this nested form, because- We only get to see
ScrutOccs ong, in its RHS - The interesting call patterns in
restapply only tof - Specialising
fandgfor those call patterns duplicatesbindstwice: We keep one copy ofbindin the originalf, one copy ofbindin$sfand another specialised copy$sbind(containing$sg) in$sf.
- We only get to see
So for SpecConstr, we should float out binds (removing potential join-point-ness)
binds; rest[f:=\xs -> g as]
Because now all call patterns of f directly apply to g and might match up
with one of the ScrutOccs in its RHS, while only needing a single duplicate of
bind.
The idea works around some of the badness in #14951 and makes fixing #14844 less important.
Edited by Sebastian Graf