[GHC] #14626: No need to enter a scrutinised value

GHC ghc-devs at haskell.org
Tue Jan 2 12:47:23 UTC 2018


#14626: No need to enter a scrutinised value
-------------------------------------+-------------------------------------
           Reporter:  heisenbug      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
           Keywords:  performance    |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  #13861
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 While analysing the output of #13861 I stumbled over an unnecessary
 pessimisation in handling of scrutinised values. With words of Simon (from
 https://phabricator.haskell.org/D4267 with minor edits added):

 Interesting. Yes, please make a ticket! (And transfer the info below into
 it.)

 I think the issue is this. Given (the STG-ish code)
 {{{#!hs
 data Colour = Red | Green | Blue
 f x = case x of y
            Red -> Green
            DEFAULT -> y
 }}}
 (here `y` is the case binder) we can just return `x` rather than entering
 it in DEFAULT branch, because `y` will be fully evaluated and its pointer
 will be correctly tagged.


 You absolutely can't check for an `OccName` of `"wild"`!! That is neither
 necessary nor sufficient :-).

 Instead, check `isEvaldUnfolding (idUnfolding y)`. See `Note [Preserve
 evaluatedness]` in `CoreTidy.hs`. And be sure to augment that note if you
 make the change.

 I would expect perf benefits to be small on average, but it's simple to
 implement.

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


More information about the ghc-tickets mailing list