summaryrefslogtreecommitdiff
path: root/compiler/coreSyn/CoreSyn.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2019-10-25 13:58:33 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2019-10-25 16:14:32 +0100
commit011ea5548464c3444d61cfc0c0486ebac1d47199 (patch)
tree2b3753cb51ae01438fb9e8c8d27bef089205dfa0 /compiler/coreSyn/CoreSyn.hs
parent2d2cc76ffb781d01c800608cd8be05cca67ac4c0 (diff)
downloadhaskell-wip/T17294.tar.gz
Better arity for join pointswip/T17294
A join point was getting too large an arity, leading to #17294. I've tightened up the invariant: see CoreSyn, Note [Invariants on join points], invariant 2b
Diffstat (limited to 'compiler/coreSyn/CoreSyn.hs')
-rw-r--r--compiler/coreSyn/CoreSyn.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/compiler/coreSyn/CoreSyn.hs b/compiler/coreSyn/CoreSyn.hs
index d94761b237..e3ad4715f1 100644
--- a/compiler/coreSyn/CoreSyn.hs
+++ b/compiler/coreSyn/CoreSyn.hs
@@ -681,9 +681,21 @@ Join points must follow these invariants:
2. For join arity n, the right-hand side must begin with at least n lambdas.
No ticks, no casts, just lambdas! C.f. CoreUtils.joinRhsArity.
- 2a. Moreover, this same constraint applies to any unfolding of the binder.
- Reason: if we want to push a continuation into the RHS we must push it
- into the unfolding as well.
+ 2a. Moreover, this same constraint applies to any unfolding of
+ the binder. Reason: if we want to push a continuation into
+ the RHS we must push it into the unfolding as well.
+
+ 2b. The Arity (in the IdInfo) of a join point is the number of value
+ binders in the top n lambdas, where n is the join arity.
+
+ So arity <= join arity; the former counts only value binders
+ while the latter counts all binders.
+ e.g. Suppose $j has join arity 1
+ let j = \x y. e in case x of { A -> j 1; B -> j 2 }
+ Then its ordinary arity is also 1, not 2.
+
+ The arity of a join point isn't very important; but short of setting
+ it to zero, it is helpful to have an invariant. E.g. #17294.
3. If the binding is recursive, then all other bindings in the recursive group
must also be join points.