[Git][ghc/ghc][wip/T22404] Small improvement

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Sat Jul 22 22:38:04 UTC 2023



Simon Peyton Jones pushed to branch wip/T22404 at Glasgow Haskell Compiler / GHC


Commits:
2d15bc68 by Simon Peyton Jones at 2023-07-22T23:37:43+01:00
Small improvement

- - - - -


1 changed file:

- compiler/GHC/Core/Opt/OccurAnal.hs


Changes:

=====================================
compiler/GHC/Core/Opt/OccurAnal.hs
=====================================
@@ -2181,12 +2181,10 @@ occ_anal_lam_tail env expr@(Lam {})
         in go env1 (bndr1 : rev_bndrs) expr
 
     go env rev_bndrs expr
-      = let bndrs = reverse rev_bndrs in
-        addInScope env bndrs $ \env ->
+      = addInScope env rev_bndrs $ \env ->
         let !(WUD usage expr') = occ_anal_lam_tail env expr
-            bndrs' = tagLamBinders usage bndrs
-        in WUD (usage `addLamCoVarOccs` bndrs)
-               (mkLams bndrs' expr')
+        in WUD (usage `addLamCoVarOccs` rev_bndrs)
+               (foldl (\e b -> Lam (tagLamBinder usage b) e) expr' rev_bndrs)
          -- addLamCoVarOccs: see Note [Gather occurrences of coercion variables]
 
 -- For casts, keep going in the same lambda-group
@@ -2918,7 +2916,10 @@ isRhsEnv (OccEnv { occ_encl = cxt }) = case cxt of
 addInScope :: OccEnv -> [Var] -> (OccEnv -> WithUsageDetails a)
            -> WithUsageDetails a
 {-# INLINE addInScope #-}
--- This function is called a lot, so we want to inline the fast path
+-- This function is called a lot, so we inline it so we don't
+-- have to allocate and then call the thing_inside
+--
+-- NB: the order of binders does not matter
 addInScope env bndrs thing_inside
   = WUD uds' res
   where



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2d15bc68a24a560c4f14778ab09df0f320c97ac0
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/20230722/d6d28a15/attachment-0001.html>


More information about the ghc-commits mailing list