diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-12-24 14:44:31 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-12-24 14:44:31 +0000 |
commit | f251bf5827aa565f7c21e1833832fa4a1150ef41 (patch) | |
tree | 8cc28ce56e6cc147218ee9901467d708bcd14876 /libraries/base/Data/List.hs | |
parent | 5d608279249f4960fc7058a4f4a4ad41aa940887 (diff) | |
download | haskell-f251bf5827aa565f7c21e1833832fa4a1150ef41.tar.gz |
Make sum and product INLINABLE
This was causing the bad behaviour in Trac #7507,
because 'sum' wasn't getting specialised to Int64.
It also deals with Trac #4321, which had the same cause.
This has a big effect on some nofib programs too:
--------------------------------------------------------------------------------
Program Allocs Runtime Elapsed TotalMem
------------------------------------------------------------------------
bernouilli -2.6% -2.0% -2.0% +0.0%
fft2 -23.8% 0.09 0.09 -16.7%
fluid -4.4% 0.01 0.01 +0.0%
hidden -3.2% +2.1% +1.8% +0.0%
integrate -38.0% -47.7% -47.7% -1.0%
x2n1 -30.2% 0.01 0.01 -50.0%
------------------------------------------------------------------------
Min -38.0% -47.7% -47.7% -50.0%
Max +0.4% +11.2% +11.8% +6.9%
Geometric Mean -1.3% +0.2% +0.2% -0.8%
Diffstat (limited to 'libraries/base/Data/List.hs')
-rw-r--r-- | libraries/base/Data/List.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libraries/base/Data/List.hs b/libraries/base/Data/List.hs index 9d09c0a475..efd0fd105e 100644 --- a/libraries/base/Data/List.hs +++ b/libraries/base/Data/List.hs @@ -1033,8 +1033,13 @@ foldl1' _ [] = errorEmptyList "foldl1'" {-# SPECIALISE sum :: [Int] -> Int #-} {-# SPECIALISE sum :: [Integer] -> Integer #-} +{-# INLINABLE sum #-} {-# SPECIALISE product :: [Int] -> Int #-} {-# SPECIALISE product :: [Integer] -> Integer #-} +{-# INLINABLE product #-} +-- We make 'sum' and 'product' inlinable so that we get specialisations +-- at other types. See, for example, Trac #7507. + -- | The 'sum' function computes the sum of a finite list of numbers. sum :: (Num a) => [a] -> a -- | The 'product' function computes the product of a finite list of numbers. |