| ... |
... |
@@ -1127,7 +1127,7 @@ occAnalNonRecRhs !env lvl imp_rule_edges mb_join bndr rhs |
|
1127
|
1127
|
-- returned by of occAnalLamTail. It's totally OK for them to mismatch;
|
|
1128
|
1128
|
-- hence adjust the UDs from the RHS
|
|
1129
|
1129
|
|
|
1130
|
|
- WUD adj_rhs_uds final_rhs = adjustNonRecRhs (joinPointHoodArity mb_join) $
|
|
|
1130
|
+ WUD adj_rhs_uds final_rhs = adjustNonRecRhs mb_join $
|
|
1131
|
1131
|
occAnalLamTail rhs_env rhs
|
|
1132
|
1132
|
final_bndr_with_rules
|
|
1133
|
1133
|
| noBinderSwaps env = bndr -- See Note [Unfoldings and rules]
|
| ... |
... |
@@ -1217,7 +1217,7 @@ occAnalRec !_ lvl |
|
1217
|
1217
|
= WUD body_uds binds
|
|
1218
|
1218
|
| otherwise
|
|
1219
|
1219
|
= let (bndr', mb_join) = tagNonRecBinder lvl occ bndr
|
|
1220
|
|
- !(WUD rhs_uds' rhs') = adjustNonRecRhs (joinPointHoodArity mb_join) wtuds
|
|
|
1220
|
+ !(WUD rhs_uds' rhs') = adjustNonRecRhs mb_join wtuds
|
|
1221
|
1221
|
in WUD (body_uds `andUDs` rhs_uds')
|
|
1222
|
1222
|
(NonRec bndr' rhs' : binds)
|
|
1223
|
1223
|
where
|
| ... |
... |
@@ -2621,7 +2621,7 @@ occAnal env app@(App _ _) |
|
2621
|
2621
|
= occAnalApp env (collectArgsTicks tickishFloatable app)
|
|
2622
|
2622
|
|
|
2623
|
2623
|
occAnal env expr@(Lam {})
|
|
2624
|
|
- = adjustNonRecRhs Nothing $ -- Nothing <=> markAllManyNonTail
|
|
|
2624
|
+ = adjustNonRecRhs NotJoinPoint $ -- NotJoinPoint <=> markAllManyNonTail
|
|
2625
|
2625
|
occAnalLamTail env expr
|
|
2626
|
2626
|
|
|
2627
|
2627
|
occAnal env (Case scrut bndr ty alts)
|
| ... |
... |
@@ -2749,7 +2749,7 @@ occAnalApp env (Var fun, args, ticks) |
|
2749
|
2749
|
-- This caused #18296
|
|
2750
|
2750
|
| fun `hasKey` runRWKey
|
|
2751
|
2751
|
, [t1, t2, arg] <- args
|
|
2752
|
|
- , WUD usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg
|
|
|
2752
|
+ , WUD usage arg' <- adjustNonRecRhs (JoinPoint TrueJoinPoint 1) $ occAnalLamTail env arg
|
|
2753
|
2753
|
= let app_out = mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']
|
|
2754
|
2754
|
in WUD usage app_out
|
|
2755
|
2755
|
|
| ... |
... |
@@ -3975,21 +3975,21 @@ lookupOccInfoByUnique (UD { ud_env = env |
|
3975
|
3975
|
-------------------
|
|
3976
|
3976
|
-- See Note [Adjusting right-hand sides]
|
|
3977
|
3977
|
|
|
3978
|
|
-adjustNonRecRhs :: Maybe JoinArity
|
|
|
3978
|
+adjustNonRecRhs :: JoinPointHood
|
|
3979
|
3979
|
-> WithTailUsageDetails CoreExpr
|
|
3980
|
3980
|
-> WithUsageDetails CoreExpr
|
|
3981
|
3981
|
-- ^ This function concentrates shared logic between occAnalNonRecBind and the
|
|
3982
|
3982
|
-- AcyclicSCC case of occAnalRec.
|
|
3983
|
3983
|
-- It returns the adjusted rhs UsageDetails combined with the body usage
|
|
3984
|
|
-adjustNonRecRhs mb_join_arity (WTUD (TUD rhs_ja uds) rhs)
|
|
|
3984
|
+adjustNonRecRhs mb_join (WTUD (TUD rhs_ja uds) rhs)
|
|
3985
|
3985
|
= WUD (adjustTailUsage exact_join rhs uds) rhs
|
|
3986
|
3986
|
where
|
|
3987
|
3987
|
exact_join =
|
|
3988
|
|
- case mb_join_arity of
|
|
3989
|
|
- Nothing -> Nothing
|
|
3990
|
|
- Just ja' ->
|
|
|
3988
|
+ case mb_join of
|
|
|
3989
|
+ NotJoinPoint -> Nothing
|
|
|
3990
|
+ JoinPoint { joinPointArity = ja', joinPointType = ty } ->
|
|
3991
|
3991
|
if ja' == rhs_ja
|
|
3992
|
|
- then Just TrueJoinPoint
|
|
|
3992
|
+ then Just ty
|
|
3993
|
3993
|
else Nothing
|
|
3994
|
3994
|
|
|
3995
|
3995
|
adjustTailUsage :: HasDebugCallStack
|
| ... |
... |
@@ -4120,11 +4120,8 @@ decideRecJoinPointHood :: TopLevelFlag -> UsageDetails |
|
4120
|
4120
|
-> [CoreBndr] -> Maybe JoinPointType
|
|
4121
|
4121
|
decideRecJoinPointHood lvl usage bndrs = do
|
|
4122
|
4122
|
bndrsNE <- NE.nonEmpty bndrs
|
|
4123
|
|
- res <- Semi.sconcat <$> traverse ok bndrsNE -- Invariant 3: Either all are join points or none are
|
|
4124
|
|
- pprTraceM "decideRecJoinPointHood" $
|
|
4125
|
|
- vcat [ text "bndrs:" <+> ppr bndrs
|
|
4126
|
|
- , text "res:" <+> ppr res ]
|
|
4127
|
|
- return res
|
|
|
4123
|
+ -- Invariant 3: Either all are join points or none are
|
|
|
4124
|
+ Semi.sconcat <$> traverse ok bndrsNE
|
|
4128
|
4125
|
where
|
|
4129
|
4126
|
ok bndr = okForJoinPoint lvl bndr (lookupTailCallInfo usage bndr)
|
|
4130
|
4127
|
|
| ... |
... |
@@ -4132,10 +4129,11 @@ okForJoinPoint :: TopLevelFlag -> Id -> TailCallInfo -> Maybe JoinPointType |
|
4132
|
4129
|
-- See Note [Invariants on join points]; invariants cited by number below.
|
|
4133
|
4130
|
-- Invariant 2 is always satisfiable by the simplifier by eta expansion.
|
|
4134
|
4131
|
okForJoinPoint lvl bndr tail_call_info
|
|
4135
|
|
- | Just join_ty <- joinId_maybe bndr
|
|
|
4132
|
+ | isJoinId bndr
|
|
4136
|
4133
|
-- A current join point should still be one!
|
|
4137
|
4134
|
= warnPprTrace lost_join "Lost join point" lost_join_doc $
|
|
4138
|
|
- Just join_ty
|
|
|
4135
|
+ mb_valid_join
|
|
|
4136
|
+ -- NB: we might downgrade 'TrueJoinPoint' to 'QuasiJoinPoint'.
|
|
4139
|
4137
|
| otherwise
|
|
4140
|
4138
|
= mb_valid_join
|
|
4141
|
4139
|
where
|