Storable and constant memory

Simon Peyton-Jones simonpj at microsoft.com
Fri Apr 23 03:27:02 EDT 2010


Bother.   It seems like a good improvement to SpecConstr anyway.  But it's disappointing that it doesn't hit this case.  In fact it seems that it should.  It's not ok to discard a 'touch' but it's fine to move it around.  Maybe what we want is primOpIsCheap?  Which is currently defined to be the same as primOpOkForSpeculation, but perhaps it should not be.

Simon

| -----Original Message-----
| From: Roman Leshchinskiy [mailto:rl at cse.unsw.edu.au]
| Sent: 23 April 2010 07:55
| To: Simon Peyton-Jones
| Cc: Haskell Libraries
| Subject: Re: Storable and constant memory
| 
| Simon,
| 
| On 23/04/2010, at 16:49, Simon Peyton-Jones wrote:
| 
| > | foo v x = ... case readIntOffAddr# p# i# realWorld# of { (# s#,  n# #) ->
| > |               case touch# fp s# of { _ ->
| >                foo v (Just (I# n# }})) ...
| >
| > I'll implement that fix.  It should catch cases like this where the primops
| involves are
| > 	- ok-for-speculation
| > 	- have just one result (ie only one case alternative
| 
| I don't think touch# is ok-for-speculation.
| 
| primop TouchOp "touch#" GenPrimOp
|    o -> State# RealWorld -> State# RealWorld
|    with
|    has_side_effects = True
| 
| Note the has_side_effects part. In fact, wouldn't it be eliminated altogether
| in this case if it was ok-for-speculation?
| 
| Roman
| 
| 



More information about the Libraries mailing list