summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Solver
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-12-22 11:02:35 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-27 19:05:18 -0500
commit382cd3b0c0a69d8e85e1588dc69b743c4a721818 (patch)
tree0adee868f71d686455597a621c091a9b57f5d272 /compiler/GHC/Tc/Solver
parent30500a4f8421ec7624316005f69c5ca252dbc37b (diff)
downloadhaskell-382cd3b0c0a69d8e85e1588dc69b743c4a721818.tar.gz
Rewrite.split: Fix reboxing
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.
Diffstat (limited to 'compiler/GHC/Tc/Solver')
-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'