Note [Adding evaluatedness info to pattern-bound variables]
addEvals records the evaluated-ness of the bound variables of
a case pattern. This is *important*. Consider
data T = T !Int !Int
case x of { T a b -> T (a+1) b }
We really must record that b is already evaluated so that we don't
go and re-evaluate it when constructing the result.
See Note [Strict fields in Core] in GHC.Core.
NB: simplLamBndrs preserves this eval info
In addition to handling data constructor fields with !s, addEvals
also records the fact that the result of seq# is always in WHNF.
See Note [seq# magic] in GHC.Types.Id.Make. Example (#15226):
case seq# v s of
(# s', v' #) -> E
we want the compiler to be aware that v' is in WHNF in E.
Open problem: we don't record that v itself is in WHNF (and we can't
do it here). The right thing is to do some kind of binder-swap;
see #15226 for discussion. References 2
- Strict fields in Core GHC.Core
- seq# magic GHC.Types.Id.Make
Referenced by 3
- GHC.Core.Opt.Simplify.Iteration call site ×2
- seq# magic GHC.Types.Id.Make