summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-12-22 11:02:35 -0500
committerBen Gamari <ben@smart-cactus.org>2021-02-18 14:14:02 -0500
commit2bb44a1b0a771ea27641a468000aab11902fc586 (patch)
treea78ece4cefc45682ec32cfc471db901c32e8fb5b
parent70749a607d5925022c10ced2b1a91fe44ff22b5e (diff)
downloadhaskell-wip/solver-perf.tar.gz
Rewrite.split: Fix reboxingwip/solver-perf
As noted in #19102, we would previously ended up reboxing the tuple result of `split`'s worker and then immediately take apart the boxed tuple to again unpack it into an unboxed result. Fixes #19102.
-rw-r--r--compiler/GHC/Tc/Solver/Rewrite.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/GHC/Tc/Solver/Rewrite.hs b/compiler/GHC/Tc/Solver/Rewrite.hs
index 76500f0519..6300215d2a 100644
--- a/compiler/GHC/Tc/Solver/Rewrite.hs
+++ b/compiler/GHC/Tc/Solver/Rewrite.hs
@@ -1017,10 +1017,13 @@ split_pi_tys' :: Type -> ([TyCoBinder], Type, Bool)
split_pi_tys' ty = split ty ty
where
-- put common cases first
- split _ (ForAllTy b res) = let (bs, ty, _) = split res res
+ split _ (ForAllTy b res) = let -- This bang is necessary lest we see rather
+ -- terrible reboxing, as noted in #19102.
+ !(bs, ty, _) = split res res
in (Named b : bs, ty, True)
split _ (FunTy { ft_af = af, ft_mult = w, ft_arg = arg, ft_res = res })
- = let (bs, ty, named) = split res res
+ = let -- See #19102
+ !(bs, ty, named) = split res res
in (Anon af (mkScaled w arg) : bs, ty, named)
split orig_ty ty | Just ty' <- coreView ty = split orig_ty ty'