[GHC] #8326: Place heap checks common in case alternatives before the case

GHC ghc-devs at haskell.org
Sat Sep 27 22:33:37 UTC 2014


#8326: Place heap checks common in case alternatives before the case
-------------------------------------+-------------------------------------
              Reporter:  jstolarek   |            Owner:
                  Type:  task        |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Compiler    |          Version:  7.7
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:  #1498
             Test Case:              |
              Blocking:  8317        |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 I do not understand the theory here—what is the (not-yet-implemented
 version of) `isTrue#` supposed to accomplish? If I hand it `12#`, it will
 dutifully tell me `False`. What exactly have I learned from that? Either I
 meant for it to return `True` and I just got a wrong answer or I just used
 a very confusingly-named function to see if something equals `1#`. I could
 fake C-style booleans if I wanted using `isFalse`, but it would be much
 clearer to just explicitly compare something to zero. If you wanted to
 actually get some kind of safety, you'd need something more invasive, with
 more potential to slow things down, like maybe

 {{{#!hs
 isTrue# x | tagToEnum# ((x `orI#` 1#) ==# 1#)  = tagToEnum# x
           | otherwise                          = error "Oops"
 }}}

 I just don't see how the proposed `isTrue#` offers any real advantage over
 `tagToEnum#`. Using primops is always playing with fire, and something
 that looks like a safety net but really isn't just invites careless
 errors.

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


More information about the ghc-tickets mailing list