GHC: Ticket #5344: CSE should look through coercions
http://ghc.haskell.org/trac/ghc/ticket/5344
<p>
This is probably a known limitation of the CSE pass, but there doesn't appear to be a ticket so I'll make one.
</p>
<p>
Consider the module:
</p>
<pre class="wiki">module M where
newtype Id a = Id a
f (a, b) = (Id a, b)
g (a, b) = (a, b)
</pre><p>
Compiling this with <tt>ghc -ddump-simpl -dsuppress-all -O2</tt>, we get
</p>
<pre class="wiki">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) }
</pre><p>
We see that <tt>g</tt> shares its argument tuple, but <tt>f</tt> allocates a new copy of it. Ideally <tt>f</tt> would also share its argument tuple, and would look like this:
</p>
<pre class="wiki">f = \ (@ t_adi) (@ a_adj) (ds_ddn :: (a_adj, t_adi)) -> ds_ddn `cast` ...
</pre>en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/5344
Trac 1.0.9iglooMon, 07 Nov 2011 00:25:58 GMTowner, milestone set
http://ghc.haskell.org/trac/ghc/ticket/5344#comment:1
http://ghc.haskell.org/trac/ghc/ticket/5344#comment:1
<ul>
<li><strong>owner</strong>
set to <em>simonpj</em>
</li>
<li><strong>milestone</strong>
set to <em>7.6.1</em>
</li>
</ul>
<p>
Simon, does this seem feasible?
</p>
TicketsimonpjMon, 07 Nov 2011 23:59:18 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/5344#comment:2
http://ghc.haskell.org/trac/ghc/ticket/5344#comment:2
<ul>
<li><strong>milestone</strong>
changed from <em>7.6.1</em> to <em>_|_</em>
</li>
</ul>
<p>
You want to answer the question "Are these two expressions <tt>e1</tt>, <tt>e2</tt> equal modulo a coercion, so that <tt>e1</tt> = <tt>e2 |> co</tt>?" I'm sure it's possible to do that, but I don't see how to do it efficiently.
</p>
<p>
Nice idea, though!
</p>
<p>
I'll milestone for bottom unless someone comes up with a plausible implementation.
</p>
<p>
Simon
</p>
TicketslyfoxSun, 22 Nov 2015 11:38:31 GMTcc set
http://ghc.haskell.org/trac/ghc/ticket/5344#comment:3
http://ghc.haskell.org/trac/ghc/ticket/5344#comment:3
<ul>
<li><strong>cc</strong>
<em>slyfox</em> added
</li>
</ul>
Ticket