summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Opt/Arity.hs
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2022-09-28 16:36:08 +0200
committerSebastian Graf <sebastian.graf@kit.edu>2022-09-29 17:04:20 +0200
commit5a535172d13b30c94766751d0bc21a494b8858ed (patch)
tree6054a3cbc51276b4ad230ca25356b591b4176291 /compiler/GHC/Core/Opt/Arity.hs
parent6a2eec98d9f5c3f5d735042f0d7bb65d0dbb3323 (diff)
downloadhaskell-wip/T22231.tar.gz
Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)wip/T22231
Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231
Diffstat (limited to 'compiler/GHC/Core/Opt/Arity.hs')
-rw-r--r--compiler/GHC/Core/Opt/Arity.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/GHC/Core/Opt/Arity.hs b/compiler/GHC/Core/Opt/Arity.hs
index 77df389dfb..922c79b746 100644
--- a/compiler/GHC/Core/Opt/Arity.hs
+++ b/compiler/GHC/Core/Opt/Arity.hs
@@ -977,7 +977,7 @@ idDemandOneShots bndr
call_arity = idCallArity bndr
dmd_one_shots :: [OneShotInfo]
- -- If the demand info is Cx(C1(C1(.))) then we know that an
+ -- If the demand info is C(x,C(1,C(1,.))) then we know that an
-- application to one arg is also an application to three
dmd_one_shots = argOneShots (idDemandInfo bndr)
@@ -1086,10 +1086,10 @@ uses info from both Call Arity and demand analysis.
We may have /more/ call demands from the calls than we have lambdas
in the binding. E.g.
let f1 = \x. g x x in ...(f1 p q r)...
- -- Demand on f1 is Cx(C1(C1(L)))
+ -- Demand on f1 is C(x,C(1,C(1,L)))
let f2 = \y. error y in ...(f2 p q r)...
- -- Demand on f2 is Cx(C1(C1(L)))
+ -- Demand on f2 is C(x,C(1,C(1,L)))
In both these cases we can eta expand f1 and f2 to arity 3.
But /only/ for called-once demands. Suppose we had
@@ -2522,11 +2522,11 @@ Let's take the simple example of #21261, where `g` (actually, `f`) is defined as
g c = c 1 2 + c 3 4
Then this is how the pieces are put together:
- * Demand analysis infers `<SCS(C1(L))>` for `g`'s demand signature
+ * Demand analysis infers `<SC(S,C(1,L))>` for `g`'s demand signature
* When the Simplifier next simplifies the argument in `g (\x y. e x y)`, it
looks up the *evaluation context* of the argument in the form of the
- sub-demand `CS(C1(L))` and stores it in the 'SimplCont'.
+ sub-demand `C(S,C(1,L))` and stores it in the 'SimplCont'.
(Why does it drop the outer evaluation cardinality of the demand, `S`?
Because it's irrelevant! When we simplify an expression, we do so under the
assumption that it is currently under evaluation.)
@@ -2535,7 +2535,7 @@ Then this is how the pieces are put together:
* Then the simplifier takes apart the lambda and simplifies the lambda group
and then calls 'tryEtaReduce' when rebuilding the lambda, passing the
- evaluation context `CS(C1(L))` along. Then we simply peel off 2 call
+ evaluation context `C(S,C(1,L))` along. Then we simply peel off 2 call
sub-demands `Cn` and see whether all of the n's (here: `S=C_1N` and
`1=C_11`) were strict. And strict they are! Thus, it will eta-reduce
`\x y. e x y` to `e`.