[GHC] #15226: GHC doesn't know that seq# produces something in WHNF

GHC ghc-devs at haskell.org
Wed Jun 6 20:08:18 UTC 2018


#15226: GHC doesn't know that seq# produces something in WHNF
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  merge
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4796
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by dfeuer):

 * status:  patch => merge


Comment:

 I think this is likely simple enough to merge.

 We still don't mark the ''argument'' to `seq#` as evaluated in the case
 branch:

 {{{#!hs
 do
   _ <- evaluate x
   pure (Str x)
 }}}

 will still think it has to force `x` again. I suspect there are likely
 users doing such things. I think the fix should be really simple, but I
 don't know how to do it. We should (I believe) rewrite

 {{{#!hs
 case seq# x s of
   (# s', x' #) -> E
 }}}

 to

 {{{#!hs
 case seq# x s of
   (# s', x' #) -> E [x -> x']
 }}}

 In principle, we could do something like that for `spark#` as well, but
 it's probably better to let threads fizzle than to let users rely on the
 optimizer to make their parallel code do what they expect.

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


More information about the ghc-tickets mailing list