[GHC] #11781: Improve common sub-expression
GHC
ghc-devs at haskell.org
Tue Apr 5 10:02:52 UTC 2016
#11781: Improve common sub-expression
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2074
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
Ah, the problem seems to triggered by different Core, but not in T9020,
but rather in GHC.Base. And indeed, the simplifier phase after float out
uses more memory with the patch applied.
What are the changes that could have caused this? Likely this:
Before
{{{
7af6f512e836b8b3376592bbd63e1ae5
$fMonadIO :: Monad IO
DFunId
{- Strictness: m, Inline: [ALWAYS] CONLIKE,
Unfolding: DFun:.
@ IO
$fMonadIO_$cp1Monad
bindIO
thenIO
returnIO
$fMonadIO_$cfail -}
}}}
After
{{{
d1aceb0a764a371523ef868c174b2704
$fMonadIO :: Monad IO
DFunId
{- Strictness: m, Inline: [ALWAYS] CONLIKE,
Unfolding: DFun:.
@ IO
$fMonadIO_$cp1Monad
bindIO
$fApplicativeIO_$c*>
$fMonadIO_$creturn
$fMonadIO_$cfail -}
}}}
Note that `(>>)` now goes through Applicative, and not through `thenIO` as
before. And that is obviously more expensive when simplifying the `return
() >> return () >> ...` chains:
{{{
42258bccfed0ab422b11c0c7ba4ead55
$fApplicativeIO_$c*> :: IO a -> IO b -> IO b
{- Arity: 3, HasNoCafRefs,
Strictness: <C(S(SL)),1*C1(U(U,A))><L,1*C1(U(U,U))><S,U>,
Inline: INLINE (sat-args=2),
Unfolding: InlineRule (2, False, False)
(\ @ a @ b (m :: IO a) (k :: IO b) (eta :: State#
RealWorld)[OneShot] ->
(bindIO @ a @ b m (\ (ds :: a) -> k)) `cast` (N:IO[0]
<b>_R) eta)
`cast`
(forall (a :: <*>_N) (b :: <*>_N).
<IO a>_R ->_R <IO b>_R ->_R Sym (N:IO[0] <b>_R)) -}
}}}
Also `return` itself is now implemented via
{{{
a2f6e8e629337f5fbb3dfb5d4b7caaa8
$fMonadIO_$creturn :: a -> IO a
{- Arity: 2, HasNoCafRefs, Strictness: <L,U><S,U>,
Unfolding: InlineRule (0, True, True)
returnIO1 `cast` (forall (a :: <*>_N). <a>_R ->_R Sym
(N:IO[0] <a>_R)) -}
}}}
I’m attaching both interface dumps, in case anyone wants to have a closer
look.
Does this analysis sound plausible?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11781#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list