summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2022-11-17 16:08:40 +0100
committerAndreas Klebinger <klebinger.andreas@gmx.at>2022-11-21 14:37:54 +0100
commitce608479c7f40a9899a6448379d05861bee77b41 (patch)
tree156d926831625eaaaab86f7c291aa9e74c9a5ca2
parent74ca6191fa0dbbe8cee3dc53741b8d59fbf16b09 (diff)
downloadhaskell-wip/andreask/92-dlist.tar.gz
Fix #22425 - Broken eta-expansion over expensive work.wip/andreask/92-dlist
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 -------------------------
-rw-r--r--compiler/GHC/Core/Opt/Arity.hs4
1 files changed, 2 insertions, 2 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]