Rational for the special case in mkWWcpr_help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Rational for the special case in mkWWcpr_help

Spiwack, Arnaud
Dear all,

The function mkWWcpr_help, which creates a wrapper and a worker after strictness analysis, has a special case when there is a single result of unlifted type:

Wrapper:     case (..call worker..) of x -> C x
Worker:      case (   ..body..    ) of C x -> x

But I don't understand how it is different from using (# #) as would result from the general case:

Wrapper:     case (..call worker..) of (# x #) -> C x
Worker:      case (   ..body..    ) of C x -> (# x #)

That is, my understanding of the latter is that it would yield the exact same code. I'm obviously missing something, I'd love to know what.

Best,
Arnaud

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

RE: Rational for the special case in mkWWcpr_help

GHC - devs mailing list

I think it would yield the same code in the end.  Maybe it was just seeking to avoid unnecessary clutter in a particularly common case (eg returning I# x).

 

Seems to have been introduce in

commit 731f53de7930c38b5023a871146bd0ec066edf3a

Author: simonpj <unknown>

   Fri Sep 17 09:15:44 1999 +0000

 

Simon

 

From: ghc-devs <[hidden email]> On Behalf Of Spiwack, Arnaud
Sent: 05 September 2018 15:02
To: [hidden email]
Subject: Rational for the special case in mkWWcpr_help

 

Dear all,

 

The function mkWWcpr_help, which creates a wrapper and a worker after strictness analysis, has a special case when there is a single result of unlifted type:

 

Wrapper:     case (..call worker..) of x -> C x
Worker:      case (   ..body..    ) of C x -> x

 

But I don't understand how it is different from using (# #) as would result from the general case:

 

Wrapper:     case (..call worker..) of (# x #) -> C x
Worker:      case (   ..body..    ) of C x -> (# x #)

 

That is, my understanding of the latter is that it would yield the exact same code. I'm obviously missing something, I'd love to know what.

 

Best,

Arnaud


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs