[Git][ghc/ghc][wip/simplifier-tweaks] Refine the too_many_occs story

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Sat Jul 8 21:17:00 UTC 2023



Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC


Commits:
1ac91e56 by Simon Peyton Jones at 2023-07-08T22:16:34+01:00
Refine the too_many_occs story

- - - - -


1 changed file:

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


Changes:

=====================================
compiler/GHC/Core/Opt/Simplify/Iteration.hs
=====================================
@@ -4394,17 +4394,22 @@ simplLetUnfolding :: SimplEnv
 simplLetUnfolding env bind_cxt id new_rhs rhs_ty arity unf
   | isStableUnfolding unf
   = simplStableUnfolding env bind_cxt id rhs_ty arity unf
+
   | isExitJoinId id
-  = return noUnfolding -- See Note [Do not inline exit join points] in GHC.Core.Opt.Exitify
---  | isJoinId id
---  , too_many_occs (idOccInfo id)
---  = return noUnfolding
+  = -- See Note [Do not inline exit join points] in GHC.Core.Opt.Exitify
+    return noUnfolding
+
+  | isJoinId id
+  , isManyOccs (idOccInfo id)
+  = -- See Note [Heavily used join points]
+    return noUnfolding
+
   | otherwise
   = -- Otherwise, we end up retaining all the SimpleEnv
     let !opts = seUnfoldingOpts env
     in mkLetUnfolding opts (bindContextLevel bind_cxt) VanillaSrc id new_rhs
-{-
   where
+{-
     -- ToDo: document this
     too_many_occs (ManyOccs {})             = True
     too_many_occs (OneOcc { occ_n_br = n }) = n > 10
@@ -4539,6 +4544,17 @@ Wrinkles
   in GHC.Core.Opt.Simplify.Utils.  We uphold this because the join-point
   case (bind_cxt = BC_Join {}) doesn't use eta_expand.
 
+Note [Heavily used join points]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+After inining join points we can end up with
+  let $j x = <rhs>
+  in case x1 of
+     True -> case x2 of
+                True -> $j blah1
+                False -> $j blah2
+     False -> case x3 of ....
+with a huge case tree 
+
 Note [Force bottoming field]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 We need to force bottoming, or the new unfolding holds



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ac91e5664072a3380e069737f2771a7f7336a23
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/20230708/b837dad9/attachment-0001.html>


More information about the ghc-commits mailing list