Skip to content

DmdAnal: Look through unfolding of DataCon wrappers (#22241)

Sebastian Graf requested to merge wip/T22241 into master

Previously, we failed to detect that f can unbox y in the following program (T22241)

data D = D !Int

f :: Bool -> Int -> D
f x y = D (go x)
  where
    go False = y
    go True  = go False
{-# NOINLINE f #-}

That is because the demand signature for $WD was computed upfront and didn't include any boxity information.

It's far simpler not to compute demand signatures for DataCon wrappers such as $WD upfront and instead look into their unfolding at call sites. See Note [DmdAnal for DataCon wrappers] for more details.

Fixes #22241 (closed).

Edited by Sebastian Graf

Merge request reports