id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
5344,CSE should look through coercions,reinerp,simonpj,"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` ...
}}}",feature request,new,normal,_|_,Compiler,7.0.3,,cse,,Unknown/Multiple,Unknown/Multiple,Runtime performance bug,,,,,
