#3744: Comparisons against minBound/maxBound not optimised
--------------------------------------+-------------------------------------
  Reporter:  rl                       |          Owner:                  
      Type:  bug                      |         Status:  new             
  Priority:  normal                   |      Milestone:  7.2.1           
 Component:  Compiler                 |        Version:  6.13            
Resolution:                           |       Keywords:                  
  Testcase:                           |      Blockedby:                  
Difficulty:                           |             Os:  Unknown/Multiple
  Blocking:                           |   Architecture:  Unknown/Multiple
   Failure:  Runtime performance bug  |  
--------------------------------------+-------------------------------------
Changes (by rl):

  * status:  closed => new
  * resolution:  fixed =>


Comment:

 Replying to [comment:10 simonpj]:
 > The optimisation seems ok, but does this situation ever arise in
 practice?  Who asks `x < minBound`?

 Me! I jump through some hoops in vector to avoid the following problem.

 {{{
 foo :: Num a => a -> a
 {-# INLINE foo #-}
 foo x | x < 0 = error "Negative argument"
       | otherwise = e

 bar :: Word -> Word
 bar x = foo x + 1
 }}}

 I completely missed the patch, thanks a lot for this! Unfortunately, it
 doesn't handle Int8/Int16/Word8/Word16 and Int32/Word32 on 64 bit systems.
 It isn't very clear how to do this because we only have Int# and Word# in
 Core. Also, the inlining of minBound/maxBound for 64 bit types on 32 bit
 systems which this patch depends on doesn't work reliably. So this ticket
 isn't quite fixed yet but this is good progress!

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

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to