[Git][ghc/ghc][wip/andreask/94-dlist] Fix #22425 - Broken eta-expansion over expensive work.

Andreas Klebinger (@AndreasK) gitlab at gitlab.haskell.org
Mon Nov 21 13:38:15 UTC 2022



Andreas Klebinger pushed to branch wip/andreask/94-dlist at Glasgow Haskell Compiler / GHC


Commits:
81cae7b7 by Andreas Klebinger at 2022-11-21T14:35:08+01:00
Fix #22425 - Broken eta-expansion over expensive work.

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
-------------------------

- - - - -


1 changed file:

- compiler/GHC/Core/Opt/Arity.hs


Changes:

=====================================
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]
 
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81cae7b73588ad77ef2e8e0e1dbe4052ecd0155f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81cae7b73588ad77ef2e8e0e1dbe4052ecd0155f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221121/6493c562/attachment-0001.html>


More information about the ghc-commits mailing list