[GHC] #14295: tagToEnum# leads to some silly closures

GHC ghc-devs at haskell.org
Thu Sep 28 08:11:54 UTC 2017


#14295: tagToEnum# leads to some silly closures
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:  datacon-tags
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 Replying to [comment:5 simonpj]:
 > I think we can do better.  Add a `BuiltInRule` for `tagToEnum#`.
 > {{{
 > tagToEnum# Bool
 > ===>
 >   \x -> case x of
 >     0# -> False
 >     1# -> True
 >     DEFAULT -> error "blah"
 > }}}
 > The rule can fire whenever `tagToEnum#` is applied to a known type,
 albeit perhaps one without too many constructors.  It's a bit like
 inlining `tagToEnum#`.
 > }}}
 > The built-in rule mechanism works well; we can use it here too.

 Yes, I thought about that too. But it's probably really only a good idea
 if there aren't many constructors; otherwise we're inlining too much. When
 we don't inline, we should still perform a bounds check to avoid the
 thunk, no?

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


More information about the ghc-tickets mailing list