[GHC] #14865: GHC Defeats Manual Worker Wrapper with Unboxed Sum

GHC ghc-devs at haskell.org
Wed Feb 28 14:57:16 UTC 2018


#14865: GHC Defeats Manual Worker Wrapper with Unboxed Sum
-------------------------------------+-------------------------------------
        Reporter:  andrewthad        |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:  UnboxedSums
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by andrewthad):

 It's weird that trying to manually apply the static argument
 transformation (which is probably not a performance win here anyway) gets
 in the way of this. For example, the following code produces the same core
 I originally was getting:

 {{{
 findByte :: Int -> Int -> Word8 -> ByteArray -> Maybe Int
 findByte !off !len0 !w0 !arr0 = boxMaybeInt (goA off (len0 + off) w0 arr0)

 goA :: Int -> Int -> Word8 -> ByteArray -> Maybe# Int#
 goA !ix0 !end !w !arr = goB ix0 where
   goB :: Int -> Maybe# Int#
   goB !ix = if ix < end
     then if PM.indexByteArray arr ix == w
       then (# | unboxInt ix #)
       else goB (ix + 1)
     else (# (# #) | #)
 }}}

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


More information about the ghc-tickets mailing list