diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-11-17 16:08:40 +0100 |
---|---|---|
committer | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-11-21 14:35:08 +0100 |
commit | 81cae7b73588ad77ef2e8e0e1dbe4052ecd0155f (patch) | |
tree | 4ccf4bcbcfbcfb1158a1f5d25abdd14a5ab905e8 | |
parent | 36a2eebfbb2795c8311b8c63514b334ab7eb5f6e (diff) | |
download | haskell-81cae7b73588ad77ef2e8e0e1dbe4052ecd0155f.tar.gz |
Fix #22425 - Broken eta-expansion over expensive work.wip/andreask/94-dlist
Through a mistake in the latest backport we started eta-expanding over
expensive work by mistake. E.g. over <expensive> in code like:
case x of
A -> id
B -> <expensive>
We fix this by only eta-expanding over <expensive> if all other branches
are headed by an oneShot lambda.
In the long story of broken eta-expansion on 9.2/9.4 this is hopefully
the last chapter.
-------------------------
Metric Increase:
CoOpt_Read
T1969
parsing001
TcPlugin_RewritePerf
LargeRecord
-------------------------
-rw-r--r-- | compiler/GHC/Core/Opt/Arity.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/GHC/Core/Opt/Arity.hs b/compiler/GHC/Core/Opt/Arity.hs index aaca8cc93a..377deb648d 100644 --- a/compiler/GHC/Core/Opt/Arity.hs +++ b/compiler/GHC/Core/Opt/Arity.hs @@ -853,7 +853,7 @@ andArityType env (AT [] div1) at2 = andWithTail env div1 at2 andArityType env at1 (AT [] div2) = andWithTail env div2 at1 andWithTail :: ArityEnv -> Divergence -> ArityType -> ArityType -andWithTail env div1 at2@(AT lams2 _) +andWithTail env div1 at2 | isDeadEndDiv div1 -- case x of { T -> error; F -> \y.e } = at2 -- Note [ABot branches: max arity wins] @@ -861,7 +861,7 @@ andWithTail env div1 at2@(AT lams2 _) = AT [] topDiv | otherwise -- case x of { T -> plusInt <expensive>; F -> \y.e } - = AT lams2 topDiv -- We know div1 = topDiv + = takeWhileOneShot at2 -- We know div1 = topDiv -- See Note [Combining case branches: andWithTail] |