CSE should look through coercions
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` ...
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |