diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-12-22 11:02:35 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-02-18 14:14:02 -0500 |
commit | 2bb44a1b0a771ea27641a468000aab11902fc586 (patch) | |
tree | a78ece4cefc45682ec32cfc471db901c32e8fb5b | |
parent | 70749a607d5925022c10ced2b1a91fe44ff22b5e (diff) | |
download | haskell-2bb44a1b0a771ea27641a468000aab11902fc586.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.hs | 7 |
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' |