[Git][ghc/ghc][wip/T18354] Two small tweaks to Coercion.simplifyArgsWorker

Simon Peyton Jones gitlab at gitlab.haskell.org
Thu Jun 18 21:43:32 UTC 2020



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


Commits:
2a165899 by Simon Peyton Jones at 2020-06-18T22:43:06+01:00
Two small tweaks to Coercion.simplifyArgsWorker

These tweaks affect the inner loop of simplifyArgsWorker, which
in turn is called from the flattener in Flatten.hs.  This is
a key perf bottleneck to T9872{a,b,c,d}.

These two small changes have a modest but useful benefit.
No change in functionality whatsoever.

Relates to #18354

- - - - -


1 changed file:

- compiler/GHC/Core/Coercion.hs


Changes:

=====================================
compiler/GHC/Core/Coercion.hs
=====================================
@@ -1794,6 +1794,8 @@ liftCoSubstWith r tvs cos ty
 -- @lc_left@ is a substitution mapping type variables to the left-hand
 -- types of the mapped coercions in @lc@, and similar for @lc_right at .
 liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion
+{-# INLINE liftCoSubst #-}
+-- Inlining this function is worth 2% of allocation in T9872d,
 liftCoSubst r lc@(LC subst env) ty
   | isEmptyVarEnv env = mkReflCo r (substTy subst ty)
   | otherwise         = ty_co_subst lc r ty
@@ -2846,7 +2848,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs
        -> [Role]      -- Roles at which to flatten these ...
        -> [(Type, Coercion)]  -- flattened arguments, with their flattening coercions
        -> ([Type], [Coercion], CoercionN)
-    go acc_xis acc_cos lc binders inner_ki _ []
+    go acc_xis acc_cos !lc binders inner_ki _ []
+        -- The !lc makes the function strict in the lifting context
+        -- which means GHC can unbox that pair.  A modest win.
       = (reverse acc_xis, reverse acc_cos, kind_co)
       where
         final_kind = mkPiTys binders inner_ki



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a165899a6b447e74e2b02ea7b26eff1496f8eb4
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/20200618/945e56e7/attachment.html>


More information about the ghc-commits mailing list