[GHC] #12620: Allow the user to prevent floating and CSE

GHC ghc-devs at haskell.org
Thu Sep 29 09:41:58 UTC 2016


#12620: Allow the user to prevent floating and CSE
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #9520, #8457      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by duncan):

 Right, this is an initial idea and hasn't been fleshed out. Thanks for the
 probing example :-)

 So the intention is that it's a purely local thing. So in that example,
 the answer is no, we do not expect a caller far away to have to know
 anything. The idea is that evaluating "via" the noupdate field should not
 perform thunk updates, but I appreciate that may not match how thunk
 construction and update works.

 So how about something like this...

 Suppose the primitive is not on fields, but on let. This is by analogy
 with strict `let !_ =` versus strict constructor fields. The primitive
 with strictness is at use sites and a convenience for systematic use we
 can push it to constructor fields, which is defined in terms of
 constructor wrappers.

 So suppose the primitive is `let {-# NOUPDATE #-} x = ...`, and so then
 the `Yield` constructor above could perhaps be defined with a wrapper like

 {{{#!hs
 data Pipe i o r = Yield o {-# NOUPDATE #-} (Pipe i o r)

 yield o x = let {-# NOUPDATE #-} x' = x in Yield o x'
 }}}

 So in your `f x` example above then this would do very little (and indeed
 we'd want it to do precisely nothing different to the usual, by shorting
 out the extra let indirection). But if things are defined with `Yield
 (expr)` or locally ghc decides to float/push things in, then the
 expression would end up in the `let {-# NOUPDATE #-} x' = ...` and so
 there would be an effect.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12620#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list