Matching cases in SpecConstr and Rules
authorsimonpj@microsoft.com <unknown>
Wed, 5 May 2010 20:05:43 +0000 (20:05 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 5 May 2010 20:05:43 +0000 (20:05 +0000)
commit9abe297285fe213ccd804f47d253055797cf667a
treebe54f8216eed361eb7d244d07ab989552e3f7a4e
parent0e04bfecd870305bdf5945ba3ab80f314c708265
Matching cases in SpecConstr and Rules

This patch has zero effect.  It includes comments,
a bit of refactoring, and a tiny bit of commment-out
code go implement the "matching cases" idea below.

In the end I've left it disabled because while I think
it does no harm I don't think it'll do any good either.
But I didn't want to lose the idea totally. There's
a thread called "Storable and constant memory" on
the libraries@haskell.org list (Apr 2010) about it.

Note [Matching cases]
~~~~~~~~~~~~~~~~~~~~~
{- NOTE: This idea is currently disabled.  It really only works if
         the primops involved are OkForSpeculation, and, since
 they have side effects readIntOfAddr and touch are not.
 Maybe we'll get back to this later .  -}

Consider
   f (case readIntOffAddr# p# i# realWorld# of { (# s#, n# #) ->
      case touch# fp s# of { _ ->
      I# n# } } )
This happened in a tight loop generated by stream fusion that
Roman encountered.  We'd like to treat this just like the let
case, because the primops concerned are ok-for-speculation.
That is, we'd like to behave as if it had been
   case readIntOffAddr# p# i# realWorld# of { (# s#, n# #) ->
   case touch# fp s# of { _ ->
   f (I# n# } } )
compiler/specialise/Rules.lhs
compiler/specialise/SpecConstr.lhs