[GHC] #5344: CSE should look through coercions
GHC
cvs-ghc at haskell.org
Mon Jul 25 14:45:12 CEST 2011
#5344: CSE should look through coercions
---------------------------------+------------------------------------------
Reporter: reinerp | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.0.3 | Keywords: cse
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Runtime performance bug
---------------------------------+------------------------------------------
This is probably a known limitation of the CSE pass, but there doesn't
appear to be a ticket so I'll make one.
Consider the module:
{{{
module M where
newtype Id a = Id a
f (a, b) = (Id a, b)
g (a, b) = (a, b)
}}}
Compiling this with {{{ghc -ddump-simpl -dsuppress-all -O2}}}, we get
{{{
g = \ (@ t_adf) (@ t1_adg) (ds_ddl :: (t_adf, t1_adg)) -> ds_ddl
f =
\ (@ t_adi) (@ a_adj) (ds_ddn :: (a_adj, t_adi)) ->
case ds_ddn of _ { (a_aaW, b_aaX) -> (a_aaW `cast` ..., b_aaX) }
}}}
We see that {{{g}}} shares its argument tuple, but {{{f}}} allocates a new
copy of it. Ideally {{{f}}} would also share its argument tuple, and would
look like this:
{{{
f = \ (@ t_adi) (@ a_adj) (ds_ddn :: (a_adj, t_adi)) -> ds_ddn `cast` ...
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5344>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list