Nested CPR light (#19398)
While fixing #19232 (closed), it became increasingly clear that the vestigial
hack described in Note [Optimistic field binder CPR]
is complicated
and causes reboxing. Rather than make the hack worse, this patch
gets rid of it completely in favor of giving deeply unboxed parameters
the Nested CPR property. Example:
f :: (Int, Int) -> Int
f p = case p of
(x, y) | x == y = x
| otherwise = y
Based on p
's idDemandInfo
SP(SP(U),SP(U))
, we can see that both
fields of p
will be available unboxed. As a result, we give p
the
nested CPR property 1(1,1)
. When analysing the case
, the field
CPRs are transferred to the binders x
and y
, respectively, so that
we ultimately give f
the CPR property.
I took the liberty to do a bit of refactoring:
- I renamed
CprResult
("Constructed product result result") to plainCpr
. - I moved a bit of stuff around in
GHC.Core.Opt.WorkWrap.Utils
and introducedUnboxingDecision
to replace theMaybe DataConPatContext
type we used to return fromwantToUnbox
. - Since the
Outputable Cpr
instance changed anyway, I removed the leadingm
which we used to emit forConCpr
. It's just noise, especially now that we may output nested CPRs.
No changes to NoFib at all through this patch.
Fixes #19398 (closed).