
Simon Peyton Jones pushed to branch wip/T23109a at Glasgow Haskell Compiler / GHC Commits: e1482394 by Simon Peyton Jones at 2025-05-14T23:21:36-04:00 Improvements esp inline top level things not-under-lambda only if it's a function. Beware extra iterations in T18698a - - - - - 2 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -1124,7 +1124,7 @@ mkNonRecRhsCtxt lvl bndr unf -- Distressing delicacy ... has to line up with preInlineUnconditionally case idOccInfo bndr of OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 } - -> active && not (isTopLevel lvl) && not stable_unf + -> active && not stable_unf _ -> False active = isAlwaysActive (idInlineActivation bndr) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1465,7 +1465,7 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env , occ_in_lam = NotInsideLam , occ_int_cxt = int_cxt } = isNotTopLevel top_lvl -- Get rid of allocation - || (int_cxt==IsInteresting) -- Function is applied + || (int_cxt==IsInteresting && idArity bndr > 0) -- Function is applied -- || (early_phase && not (isConLikeUnfolding unf)) -- See early_phase one_occ OneOcc{ occ_n_br = 1 , occ_in_lam = IsInsideLam @@ -1632,6 +1632,7 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs unfolding = idUnfolding bndr -- arity = idArity bndr is_cheap = isCheapUnfolding unfolding + is_exp = isExpandableUnfolding unfolding uf_opts = seUnfoldingOpts env phase = sePhase env active = isActive phase (idInlineActivation bndr) @@ -1639,6 +1640,8 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs -- Check for code-size blow-up from inlining in multiple places code_dup_ok n_br + | is_top_lvl -- Don't inline top-level datacons, ever; no advantage, + , is_exp = False -- and float-out may have carefully created them | n_br == 1 = True -- No duplication | n_br >= 100 = False -- See #23627 | is_demanded = False -- Demanded => no allocation (it'll be a case expression View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e14823948401b7dad78cc4f2eddb03b2... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e14823948401b7dad78cc4f2eddb03b2... You're receiving this email because of your account on gitlab.haskell.org.