Demand: Interleave usage and strictness demands (#18903)
As outlined in #18903, interleaving usage and strictness demands not only means a more compact demand representation, but also allows us to express demands that we weren't easily able to express before. Call demands are *relative* in the sense that a call demand `Cn(cd)` on `g` says "`g` is called `n` times. *Whenever `g` is called*, the result is used according to `cd`". Example from #18903: ```hs h :: Int -> Int h m = let g :: Int -> (Int,Int) g 1 = (m, 0) g n = (2 * n, 2 `div` n) {-# NOINLINE g #-} in case m of 1 -> 0 2 -> snd (g m) _ -> uncurry (+) (g m) ``` Without the interleaved representation, we would just get `L` for the strictness demand on `g`. Now we are able to express that whenever `g` is called, its second component is used strictly in denoting `g` by `1C1(P(1P(U),SP(U)))`. This would allow Nested CPR to unbox the division, for example. Fixes #18903. While fixing regressions, I also discovered and fixed #18957. Metric Decrease: T13253-spj
Showing
- compiler/GHC/Builtin/primops.txt.pp 5 additions, 5 deletionscompiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Core/Opt/CprAnal.hs 1 addition, 1 deletioncompiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs 161 additions, 126 deletionscompiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/Pipeline.hs 1 addition, 2 deletionscompiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/SetLevels.hs 2 additions, 2 deletionscompiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify.hs 3 additions, 3 deletionscompiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs 2 additions, 2 deletionscompiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs 6 additions, 5 deletionscompiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs 5 additions, 6 deletionscompiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/CoreToStg.hs 5 additions, 5 deletionscompiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs 2 additions, 2 deletionscompiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Iface/Syntax.hs 1 addition, 1 deletioncompiler/GHC/Iface/Syntax.hs
- compiler/GHC/Stg/Lift/Analysis.hs 19 additions, 29 deletionscompiler/GHC/Stg/Lift/Analysis.hs
- compiler/GHC/Types/Demand.hs 1222 additions, 1449 deletionscompiler/GHC/Types/Demand.hs
- compiler/GHC/Types/Id.hs 1 addition, 1 deletioncompiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs 1 addition, 1 deletioncompiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs 3 additions, 3 deletionscompiler/GHC/Types/Id/Make.hs
- compiler/GHC/Utils/Outputable.hs 3 additions, 1 deletioncompiler/GHC/Utils/Outputable.hs
- testsuite/tests/arityanal/should_compile/Arity01.stderr 4 additions, 4 deletionstestsuite/tests/arityanal/should_compile/Arity01.stderr
- testsuite/tests/arityanal/should_compile/Arity02.stderr 2 additions, 2 deletionstestsuite/tests/arityanal/should_compile/Arity02.stderr
Loading
Please register or sign in to comment