[GHC] #14948: A program which benefits from a late specialisation pass
GHC
ghc-devs at haskell.org
Tue Mar 20 22:27:23 UTC 2018
#14948: A program which benefits from a late specialisation pass
-------------------------------------+-------------------------------------
Reporter: mpickering | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by mpickering):
The code in question first uses a type class to generate an overloaded
function. The overloaded function is not immediately apparent, it is
defined in terms of combinators which must be inlined and then later we
get calls of `fmap` next to a dictionary which can be specialised upon.
Diffing the core output immediately shows where the difference is. In the
bad version we have lots of calls to `fmap` which are not eliminated
because the function they are contained in is not specialised.
{{{
1486,1497c1514,1560
< -- RHS size: {terms: 13, types: 12, coercions: 13, joins: 0/0}
< $s$fGHasTypeskaK1_$cgtypes_$s$dHastypes'
< $s$fGHasTypeskaK1_$cgtypes_$s$dHastypes'
< = \ eta_B2 eta1_B1 ->
< case eta1_B1 of {
< [] -> [] `cast` <Co:4>;
< : g1_ab8Q g2_ab8R ->
< (: ((eta_B2 g1_ab8Q) `cast` <Co:2>)
< (($s$fGHasTypeskaK1_$cgtypes_$s$dHastypes' eta_B2 g2_ab8R)
< `cast` <Co:3>))
< `cast` <Co:4>
< }
---
> -- RHS size: {terms: 63, types: 791, coercions: 308, joins: 0/0}
> $s$fGHasTypeskaK1_$cgtypes1
> $s$fGHasTypeskaK1_$cgtypes1
> = \ @ f_a5xv $dApplicative_a5xx eta_B2 eta1_B1 ->
> fmap
> ($p1Applicative $dApplicative_a5xx)
> $fGeneric[]_$cto
> ((fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes8 `cast` <Co:121>)
> (case eta1_B1 of {
> [] ->
> fmap
> ($p1Applicative $dApplicative_a5xx)
> L1
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes7 `cast` <Co:22>)
> (pure $dApplicative_a5xx U1));
> : g1_abai g2_abaj ->
> fmap
> ($p1Applicative $dApplicative_a5xx)
> R1
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes6 `cast` <Co:78>)
> (<*>
> $dApplicative_a5xx
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> :*:
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes5 `cast`
<Co:28>)
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes4 `cast`
<Co:11>)
> (eta_B2 g1_abai))))
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes3 `cast` <Co:28>)
> (fmap
> ($p1Applicative $dApplicative_a5xx)
> ($s$fGHasTypeskaK1_$cgtypes2 `cast`
<Co:13>)
> ($s$fGHasTypeskaK1_$cgtypes1
$dApplicative_a5xx eta_B2 g2_abaj)))))
> }))
> `cast` <Co:7>)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14948#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list