[Git][ghc/ghc][wip/spj-unf-size] Inline on structured arguments

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Mon Nov 13 12:32:31 UTC 2023



Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC


Commits:
f56c7c18 by Simon Peyton Jones at 2023-11-13T12:32:09+00:00
Inline on structured arguments

- - - - -


1 changed file:

- compiler/GHC/Core/Opt/Simplify/Inline.hs


Changes:

=====================================
compiler/GHC/Core/Opt/Simplify/Inline.hs
=====================================
@@ -650,7 +650,8 @@ exprDigest env e = go env e []
       | Just con <- isDataConWorkId_maybe f
       = ArgIsCon (DataAlt con) (map (exprDigest env) val_args)
 
-      | DFunUnfolding {} <- unfolding
+--      | DFunUnfolding {} <- unfolding
+      | hasSomeUnfolding unfolding
       = ArgIsNot []  -- We (slightly hackily) use ArgIsNot [] for dfun applications
                      -- ($df d1 .. dn).  This is very important to encourage inlining
                      -- of overloaded functions.  Example. GHC.Base.liftM2. It has
@@ -658,6 +659,12 @@ exprDigest env e = go env e []
                      -- discount.  But the ArgDigest had better be good enough to
                      -- attract that ScrutOf discount!  We want liftM2 to be inlined
                      -- in its use in the liftA2 method of instance Applicative (ST s)
+                     --
+                     -- Actually in specrtal/puzzle I found that we got a big (40%!)
+                     -- benefit from    let newDest = ... in case (notSeen newDest) of ...
+                     -- We want to inline notSeen.  The argument has structure (its RHS)
+                     -- and in fat if we inline notSeen, newDest turns into a thunk
+                     -- (SPJ GHC log 13 Nov).
 
       | Just rhs <- expandUnfolding_maybe unfolding
       = go (zapSubstEnv env) rhs val_args



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f56c7c18fc4bb55eca89e19cb75baecc7da59b19

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f56c7c18fc4bb55eca89e19cb75baecc7da59b19
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231113/49cbf082/attachment-0001.html>


More information about the ghc-commits mailing list