[commit: ghc] master: In GHC.Real, specialise 'even' and 'odd' to Int and Integer (db5868c)

git at git.haskell.org git at git.haskell.org
Fri Aug 29 10:03:47 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/db5868cf0589b36df2948517a47930dd676974a0/ghc

>---------------------------------------------------------------

commit db5868cf0589b36df2948517a47930dd676974a0
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Aug 29 10:19:02 2014 +0100

    In GHC.Real, specialise 'even' and 'odd' to Int and Integer
    
    This was previously happening by a fluke -- they were called with those types
    in GHC.Real itself -- but my recent changes to specialisation mean that auto
    specialisations like these are not necessarily exported.
    
    Losing those specialisations made a huge difference to two performance tests
       perf/should_run/MethSharing
       perf/should_run/T9339


>---------------------------------------------------------------

db5868cf0589b36df2948517a47930dd676974a0
 libraries/base/GHC/Real.lhs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libraries/base/GHC/Real.lhs b/libraries/base/GHC/Real.lhs
index a54818f..481125a 100644
--- a/libraries/base/GHC/Real.lhs
+++ b/libraries/base/GHC/Real.lhs
@@ -517,6 +517,10 @@ showSigned showPos p x
 even, odd       :: (Integral a) => a -> Bool
 even n          =  n `rem` 2 == 0
 odd             =  not . even
+{-# SPECIALISE even :: Int -> Bool #-}
+{-# SPECIALISE odd  :: Int -> Bool #-}
+{-# SPECIALISE even :: Integer -> Bool #-}
+{-# SPECIALISE odd  :: Integer -> Bool #-}
 
 -------------------------------------------------------
 -- | raise a number to a non-negative integral power



More information about the ghc-commits mailing list