[Git][ghc/ghc][wip/T26548] Lambda arguments are values in interestingArg
Simon Peyton Jones pushed to branch wip/T26548 at Glasgow Haskell Compiler / GHC Commits: bef65cee by Simon Peyton Jones at 2026-02-10T13:21:19+00:00 Lambda arguments are values in interestingArg This matters a lot!!! - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1034,6 +1034,15 @@ Wrinkles: Conclusion: `interestingArg` should give some encouragement (NonTrivArg) to `f` when the argument is expandable. Hence `uf_expandable` in the `Var` case. +(IA5) We are keen to inline a higher-order function applied to lambda, e.g. + f (\x. blah) + where + f h = ...(h xs)... + Doing so specialises `f` to the particular argument which can make a + big difference. Note, however, that we don't want to be defeated if + the lambda is let-bound: + let h = (\x.blah) + in ...f h... -} interestingArg :: SimplEnv -> CoreExpr -> ArgSummary @@ -1059,9 +1068,7 @@ interestingArg env e = go env 0 e go env n (Lam v e) | isTyVar v = go env n e | n>0 = NonTrivArg -- (\x.b) e is NonTriv - | otherwise = ValueArg -- (\x.b) is Value - -- Having ValueArg here is very important - -- for getting higher order functions to inline + | otherwise = ValueArg -- (\x.b) is Value: see (IA5) go _ _ (Case {}) = NonTrivArg go env n (Let b e) = case go env' n e of ValueArg -> ValueArg @@ -1073,7 +1080,7 @@ interestingArg env e = go env 0 e | isConLikeId v = ValueArg -- Experimenting with 'conlike' rather that -- data constructors here (includes DFuns) -- see (IA1) in Note [Interesting arguments] - | idArity v > n = NonTrivArg -- Catches (eg) primops with arity but no unfolding + | idArity v > n = ValueArg -- See (IA5) in Note [Interesting arguments] | n > 0 = NonTrivArg -- Saturated or unknown call | otherwise -- n==0, no value arguments; look for an interesting unfolding = case idUnfolding v of View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bef65ceed4d4ff67ce67e349d133c2a6... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bef65ceed4d4ff67ce67e349d133c2a6... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)