[GHC] #11688: Bytestring break failing rewrite to breakByte and failing to eliminate boxing/unboxing

GHC ghc-devs at haskell.org
Tue Mar 8 14:16:09 UTC 2016


#11688: Bytestring break failing rewrite to breakByte and failing to eliminate
boxing/unboxing
-------------------------------------+-------------------------------------
        Reporter:  alexbiehl         |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.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:D1980
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 This comes up regularly; e.g. #10595, #7141 (maybe), #5973 (maybe), #4397
 (I bet the fix is delicate), #2271, #1434.  And #10418 is similar but for
 constructors not class ops.

 In general, I it's dangerous to match on an overloaded class op.  After
 all, did you really mean to match on `(==)` at every type? I doubt it?  In
 this case we mean `==` at type `Char`.  So the advice in comment:4 of
 #10595, is to write
 {{{
 instance Eq Char where
   (==) = eqChar

 eqChar :: Char -> Char -> Bool
 {-# INLINE [0] eqChar #-}   -- Delay inlining
 }}}
 and then make the rule be
 {{{
 {-# RULES "bsbreak" forall x chunk.
      ByteString.break (eqChar x) chunk = ...
  #-}
 }}}
 This is simple and robust.  But it does mean chaging the base library to
 use named functions for instance methods.  Probably good practice anyway.

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


More information about the ghc-tickets mailing list