diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-11-17 16:08:40 +0100 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2023-02-07 18:47:08 +0530 |
commit | 6eaf0d3dfec70d175115d666a477cf46e44e29ef (patch) | |
tree | 4dd2c0a4fb7306c738dd486d60ef96ec427a720d | |
parent | 1b48378e65e0203de83c23577fcd0f1ae4fe83be (diff) | |
download | haskell-6eaf0d3dfec70d175115d666a477cf46e44e29ef.tar.gz |
Fix #22425 - Broken eta-expansion over expensive work.
This is the 9.2 backport of !9357
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
-------------------------
(cherry picked from commit ce608479c7f40a9899a6448379d05861bee77b41)
-rw-r--r-- | compiler/GHC/Core/Opt/Arity.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/warnings/should_compile/T16282/T16282.stderr | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/compiler/GHC/Core/Opt/Arity.hs b/compiler/GHC/Core/Opt/Arity.hs index 1c6f9bed8b..66af0586f3 100644 --- a/compiler/GHC/Core/Opt/Arity.hs +++ b/compiler/GHC/Core/Opt/Arity.hs @@ -791,7 +791,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] @@ -799,7 +799,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] diff --git a/testsuite/tests/warnings/should_compile/T16282/T16282.stderr b/testsuite/tests/warnings/should_compile/T16282/T16282.stderr index a9c62b3c17..e9cc798546 100644 --- a/testsuite/tests/warnings/should_compile/T16282/T16282.stderr +++ b/testsuite/tests/warnings/should_compile/T16282/T16282.stderr @@ -5,5 +5,6 @@ T16282.hs: warning: [-Wall-missed-specialisations] Probable fix: add INLINABLE pragma on ‘Data.Foldable.$wmapM_’ T16282.hs: warning: [-Wall-missed-specialisations] - Could not specialise imported function ‘Data.Map.Internal.$fShowMap_$cshowsPrec’ - Probable fix: add INLINABLE pragma on ‘Data.Map.Internal.$fShowMap_$cshowsPrec’ + Could not specialise imported function ‘Data.Map.Internal.$w$cshowsPrec’ + when specialising ‘Data.Map.Internal.$fShowMap_$cshowsPrec’ + Probable fix: add INLINABLE pragma on ‘Data.Map.Internal.$w$cshowsPrec’ |