| ... |
... |
@@ -1059,28 +1059,27 @@ and again its arity increases (#15517) |
|
1059
|
1059
|
-}
|
|
1060
|
1060
|
|
|
1061
|
1061
|
|
|
1062
|
|
--- | Returns Just (bndr,rhs) if the binding is a join point:
|
|
1063
|
|
--- If it's a JoinId, just return it
|
|
1064
|
|
--- If it's not yet a JoinId but is always tail-called,
|
|
1065
|
|
--- make it into a JoinId and return it.
|
|
1066
|
|
--- In the latter case, eta-expand the RHS if necessary, to make the
|
|
1067
|
|
--- lambdas explicit, as is required for join points
|
|
1068
|
|
---
|
|
1069
|
|
--- Precondition: the InBndr has been occurrence-analysed,
|
|
1070
|
|
--- so its OccInfo is valid
|
|
|
1062
|
+-- | Returns @Just (bndr,rhs)@ if the binding is a join point or can be made
|
|
|
1063
|
+-- into a join point (it is always tail called). In the latter case, eta-expand
|
|
|
1064
|
+-- the RHS if necessary, to make the lambdas explicit, as is required for join points.
|
|
1071
|
1065
|
joinPointBinding_maybe :: InBndr -> InExpr -> Maybe (InBndr, InExpr)
|
|
1072
|
1066
|
joinPointBinding_maybe bndr rhs
|
|
1073
|
1067
|
| not (isId bndr)
|
|
1074
|
1068
|
= Nothing
|
|
1075
|
1069
|
|
|
|
1070
|
+ -- NB: the 'OccInfo' of the 'InBndr' may have been zapped, e.g. if we
|
|
|
1071
|
+ -- have inlined it. In this case, we may lose the join-point-hood of the
|
|
|
1072
|
+ -- original binder. A later occurrence analysis pass may recover it.
|
|
1076
|
1073
|
| isJoinId bndr
|
|
1077
|
|
- = Just (bndr, rhs)
|
|
|
1074
|
+ = case tailCallInfo (idOccInfo bndr) of
|
|
|
1075
|
+ NoTailCallInfo -> Nothing
|
|
|
1076
|
+ AlwaysTailCalled {} -> Just (bndr, rhs)
|
|
1078
|
1077
|
|
|
1079
|
1078
|
| AlwaysTailCalled join_arity <- tailCallInfo (idOccInfo bndr)
|
|
1080
|
1079
|
, (bndrs, body) <- etaExpandToJoinPoint join_arity rhs
|
|
1081
|
1080
|
, let str_sig = idDmdSig bndr
|
|
1082
|
1081
|
str_arity = count isId bndrs -- Strictness demands are for Ids only
|
|
1083
|
|
- join_bndr = bndr `asJoinId` join_arity
|
|
|
1082
|
+ join_bndr = bndr `asJoinId` join_arity
|
|
1084
|
1083
|
`setIdDmdSig` etaConvertDmdSig str_arity str_sig
|
|
1085
|
1084
|
= Just (join_bndr, mkLams bndrs body)
|
|
1086
|
1085
|
|