diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2020-06-18 15:47:52 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-23 22:50:11 -0400 |
commit | 625a7f5465d51d054c6930772412bad7d87189c5 (patch) | |
tree | 91eb8749d900eb8edd4c47e883e5f944f6ef3858 /compiler/GHC/Core | |
parent | 181516bcd6f18f22e1df3915bfca0c36524a725b (diff) | |
download | haskell-625a7f5465d51d054c6930772412bad7d87189c5.tar.gz |
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
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r-- | compiler/GHC/Core/Coercion.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Coercion.hs b/compiler/GHC/Core/Coercion.hs index 03e0d59f38..e482e14811 100644 --- a/compiler/GHC/Core/Coercion.hs +++ b/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@. 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 |