[GHC] #2163: GHC makes thunks for Integers we are strict in

GHC trac at galois.com
Mon Mar 17 19:38:56 EDT 2008


#2163: GHC makes thunks for Integers we are strict in
-----------------------------------------+----------------------------------
    Reporter:  igloo                     |       Owner:         
        Type:  run-time performance bug  |      Status:  new    
    Priority:  normal                    |   Milestone:  6.8.3  
   Component:  Compiler                  |     Version:  6.9    
    Severity:  normal                    |    Keywords:         
  Difficulty:  Unknown                   |    Testcase:         
Architecture:  Unknown                   |          Os:  Unknown
-----------------------------------------+----------------------------------
 We know that timesInteger is strict in both arguments:
 {{{
 $ ./ghc --show-iface ~/ghc/darcs/val/libraries/base/dist/build/GHC/Num.hi
 | grep -C2 "^timesInteger"
 plusInteger :: GHC.Num.Integer -> GHC.Num.Integer -> GHC.Num.Integer
   {- Arity: 2 HasNoCafRefs Strictness: SS -}
 timesInteger :: GHC.Num.Integer -> GHC.Num.Integer -> GHC.Num.Integer
   {- Arity: 2 HasNoCafRefs Strictness: SS -}
 class (GHC.Base.Eq a, GHC.Show.Show a) => Num a
 }}}
 but given this code:
 {{{
 module W where

 f :: Integer -> Integer
 f x = let x' = x + 3
       in x' * x'
 }}}
 we still make a thunk for `x'`:
 {{{
 $ ./ghc -c w.hs -O -fforce-recomp -ddump-simpl
 ==================== Tidy Core ====================
 W.lvl :: GHC.Num.Integer
 [GlobalId]
 [NoCafRefs
  Str: DmdType]
 W.lvl = GHC.Num.S# 3

 W.f :: GHC.Num.Integer -> GHC.Num.Integer
 [GlobalId]
 [Arity 1
  NoCafRefs
  Str: DmdType S]
 W.f =
   \ (x_a5h :: GHC.Num.Integer) ->
     let {
       x'_sa7 [ALWAYS Just S] :: GHC.Num.Integer
       [Str: DmdType]
       x'_sa7 = GHC.Num.plusInteger x_a5h W.lvl } in
     GHC.Num.timesInteger x'_sa7 x'_sa7
 }}}
 The same is true in both the 6.8 branch and the HEAD.

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


More information about the Glasgow-haskell-bugs mailing list