Ticket #5344 (new feature request)
CSE should look through coercions
| Reported by: | reinerp | Owned by: | simonpj |
|---|---|---|---|
| Priority: | normal | Milestone: | _|_ |
| Component: | Compiler | Version: | 7.0.3 |
| Keywords: | cse | Cc: | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Runtime performance bug | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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` ...
Change History
Note: See
TracTickets for help on using
tickets.
