[GHC] #5731: Bad code for Double literals

GHC cvs-ghc at haskell.org
Thu Dec 29 23:58:34 CET 2011


#5731: Bad code for Double literals
-------------------------------------+--------------------------------------
 Reporter:  rl                       |          Owner:                  
     Type:  bug                      |         Status:  new             
 Priority:  normal                   |      Component:  Compiler        
  Version:  7.3                      |       Keywords:                  
       Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple
  Failure:  Runtime performance bug  |       Testcase:                  
Blockedby:                           |       Blocking:                  
  Related:                           |  
-------------------------------------+--------------------------------------
 Caught by the `vector` benchmark suite. Small program:

 {{{
 foo :: [Double] -> [Double]
 foo = map f
   where
     f x = 1 / x
 }}}

 The current head generates this rather terrible code (with -O2):

 {{{
 foo3 :: GHC.Integer.Type.Integer
 foo3 = __integer 1

 foo2 :: GHC.Types.Double
 foo2 =
   case GHC.Integer.Type.doubleFromInteger foo3
   of wild_afu { __DEFAULT ->
   GHC.Types.D# wild_afu
   }

 foo1 :: GHC.Types.Double -> GHC.Types.Double
 foo1 =
   \ (eta_B1 :: GHC.Types.Double) ->
     GHC.Float.divideDouble foo2 eta_B1

 foo :: [GHC.Types.Double] -> [GHC.Types.Double]
 foo = GHC.Base.map @ GHC.Types.Double @ GHC.Types.Double foo1
 }}}

 It does generate perfectly fine code for this, though:

 {{{
 bar :: [Double] -> [Double]
 bar = map (\x -> 1/x)
 }}}

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



More information about the Glasgow-haskell-bugs mailing list