| ... |
... |
@@ -316,8 +316,8 @@ simplLazyBind :: TopLevelFlag -> RecFlag |
|
316
|
316
|
-- Precondition: Ids only, no TyVars; not a JoinId
|
|
317
|
317
|
-- Precondition: rhs obeys the let-can-float invariant
|
|
318
|
318
|
simplLazyBind top_lvl is_rec (bndr,unf_se) (bndr1,env) (rhs,rhs_se)
|
|
319
|
|
- = assert (isId bndr )
|
|
320
|
|
- assertPpr (not (isJoinId bndr)) (ppr bndr) $
|
|
|
319
|
+ = assert (isId bndr)
|
|
|
320
|
+ assertPpr (isNothing (joinPointBinding_maybe bndr rhs)) (ppr bndr) $
|
|
321
|
321
|
-- pprTrace "simplLazyBind" ((ppr bndr <+> ppr bndr1) $$ ppr rhs $$ ppr (seIdSubst rhs_se)) $
|
|
322
|
322
|
do { let !rhs_env = rhs_se `setInScopeFromE` env -- See Note [Bangs in the Simplifier]
|
|
323
|
323
|
(tvs, body) = case collectTyAndValBinders rhs of
|
| ... |
... |
@@ -399,7 +399,7 @@ simplAuxBind :: String |
|
399
|
399
|
-- Precondition: rhs satisfies the let-can-float invariant
|
|
400
|
400
|
|
|
401
|
401
|
simplAuxBind _str env bndr new_rhs
|
|
402
|
|
- | assertPpr (isId bndr && not (isJoinId bndr)) (ppr bndr) $
|
|
|
402
|
+ | assertPpr (isId bndr && isNothing (joinPointBinding_maybe bndr new_rhs)) (ppr bndr) $
|
|
403
|
403
|
isDeadBinder bndr -- Not uncommon; e.g. case (a,b) of c { (p,q) -> p }
|
|
404
|
404
|
= return (emptyFloats env, env) -- Here c is dead, and we avoid
|
|
405
|
405
|
-- creating the binding c = (a,b)
|
| ... |
... |
@@ -1905,7 +1905,7 @@ simplNonRecE :: HasDebugCallStack |
|
1905
|
1905
|
-- Otherwise it may or may not satisfy it.
|
|
1906
|
1906
|
|
|
1907
|
1907
|
simplNonRecE env from_what bndr (rhs, rhs_se) body cont
|
|
1908
|
|
- | assert (isId bndr && not (isJoinId bndr) ) $
|
|
|
1908
|
+ | assert (isId bndr && isNothing (joinPointBinding_maybe bndr rhs)) $
|
|
1909
|
1909
|
is_strict_bind
|
|
1910
|
1910
|
= -- Evaluate RHS strictly
|
|
1911
|
1911
|
simplExprF (rhs_se `setInScopeFromE` env) rhs
|
| ... |
... |
@@ -1943,7 +1943,7 @@ simplRecE :: SimplEnv |
|
1943
|
1943
|
-- Precondition: not a join-point binding
|
|
1944
|
1944
|
simplRecE env pairs body cont
|
|
1945
|
1945
|
= do { let bndrs = map fst pairs
|
|
1946
|
|
- ; massert (all (not . isJoinId) bndrs)
|
|
|
1946
|
+ ; massert (isNothing $ joinPointBindings_maybe pairs)
|
|
1947
|
1947
|
; env1 <- simplRecBndrs env bndrs
|
|
1948
|
1948
|
-- NB: bndrs' don't have unfoldings or rules
|
|
1949
|
1949
|
-- We add them as we go down
|
| ... |
... |
@@ -2051,7 +2051,7 @@ simplNonRecJoinPoint :: SimplEnv -> InId -> InExpr |
|
2051
|
2051
|
-> InExpr -> SimplCont
|
|
2052
|
2052
|
-> SimplM (SimplFloats, OutExpr)
|
|
2053
|
2053
|
simplNonRecJoinPoint env bndr rhs body cont
|
|
2054
|
|
- = assert (isJoinId bndr ) $
|
|
|
2054
|
+ = assert (isJust $ joinPointBinding_maybe bndr rhs) $
|
|
2055
|
2055
|
wrapJoinCont env cont $ \ env cont ->
|
|
2056
|
2056
|
do { -- We push join_cont into the join RHS and the body;
|
|
2057
|
2057
|
-- and wrap wrap_cont around the whole thing
|
| ... |
... |
@@ -4574,22 +4574,24 @@ simplLetUnfolding env bind_cxt id new_rhs rhs_ty arity unf |
|
4574
|
4574
|
| isStableUnfolding unf
|
|
4575
|
4575
|
= simplStableUnfolding env bind_cxt id rhs_ty arity unf
|
|
4576
|
4576
|
|
|
4577
|
|
- | freshly_born_join_point id
|
|
4578
|
|
- = -- This is a tricky one!
|
|
4579
|
|
- -- See wrinkle (JU1) in Note [Do not add unfoldings to join points at birth]
|
|
4580
|
|
- return noUnfolding
|
|
4581
|
|
-
|
|
4582
|
4577
|
| isExitJoinId id
|
|
4583
|
4578
|
= -- See Note [Do not inline exit join points] in GHC.Core.Opt.Exitify
|
|
4584
|
4579
|
return noUnfolding
|
|
4585
|
4580
|
|
|
4586
|
|
- | otherwise
|
|
4587
|
|
- = mkLetUnfolding env (bindContextLevel bind_cxt) VanillaSrc id is_join_point new_rhs
|
|
|
4581
|
+ | freshly_born_join_point
|
|
|
4582
|
+ = -- This is a tricky one!
|
|
|
4583
|
+ -- See wrinkle (JU1) in Note [Do not add unfoldings to join points at birth]
|
|
|
4584
|
+ return noUnfolding
|
|
4588
|
4585
|
|
|
|
4586
|
+ | otherwise
|
|
|
4587
|
+ = mkLetUnfolding env (bindContextLevel bind_cxt) VanillaSrc id' is_join new_rhs'
|
|
4589
|
4588
|
where
|
|
4590
|
|
- is_join_point = isJoinId id
|
|
4591
|
|
- freshly_born_join_point id = is_join_point && isManyOccs (idOccInfo id)
|
|
4592
|
|
- -- OLD: too_many_occs (OneOcc { occ_n_br = n }) = n > 10 -- See #23627
|
|
|
4589
|
+ (id', new_rhs', is_join) =
|
|
|
4590
|
+ case joinPointBinding_maybe id new_rhs of
|
|
|
4591
|
+ Nothing -> (id, new_rhs, False)
|
|
|
4592
|
+ Just (id', new_rhs') -> (id', new_rhs', True)
|
|
|
4593
|
+ freshly_born_join_point =
|
|
|
4594
|
+ is_join && (not (isJoinId id) || isManyOccs (idOccInfo id))
|
|
4593
|
4595
|
|
|
4594
|
4596
|
-------------------
|
|
4595
|
4597
|
mkLetUnfolding :: SimplEnv -> TopLevelFlag -> UnfoldingSource
|