summaryrefslogtreecommitdiff
path: root/compiler/GHC/Types/Id.hs
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2022-02-17 18:11:24 +0100
committerSebastian Graf <sebastian.graf@kit.edu>2022-04-19 12:47:52 +0200
commit79d69ad7548ef103974e77df2db6444ea031dd4b (patch)
treed74bd5e795e7f5fa640a2233cf9f556a475eb82d /compiler/GHC/Types/Id.hs
parent6810752a0764f63c3577b223bbfdc6e70dfcb33a (diff)
downloadhaskell-79d69ad7548ef103974e77df2db6444ea031dd4b.tar.gz
Assume at least one evaluation for nested SubDemands (#21081, #21133)
See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133.
Diffstat (limited to 'compiler/GHC/Types/Id.hs')
0 files changed, 0 insertions, 0 deletions