[commit: ghc] master: SPECIALIZE strictMinimum for Int and Integer (dc671a1)

git at git.haskell.org git at git.haskell.org
Mon Sep 7 11:20:51 UTC 2015


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

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

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

commit dc671a1c06736b192e4a53f580e17356ffa7224e
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Mon Sep 7 13:19:50 2015 +0200

    SPECIALIZE strictMinimum for Int and Integer
    
    This fixes a regression reported in #10788, where due to less inlining
    compared to earlier versions, we’d get worse code. With the SPECIALIZE,
    we get the good code, and moreover, the good code is in List.hs and
    _not_ inlined to the use site, so smaller code size and less compilation
    time.


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

dc671a1c06736b192e4a53f580e17356ffa7224e
 libraries/base/GHC/List.hs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libraries/base/GHC/List.hs b/libraries/base/GHC/List.hs
index ca3fb75..86ff868 100644
--- a/libraries/base/GHC/List.hs
+++ b/libraries/base/GHC/List.hs
@@ -415,6 +415,8 @@ maximum xs              =  foldl1 max xs
 strictMaximum           :: (Ord a) => [a] -> a
 strictMaximum []        =  errorEmptyList "maximum"
 strictMaximum xs        =  foldl1' max xs
+{-# SPECIALIZE  strictMaximum :: [Int] -> Int #-}
+{-# SPECIALIZE  strictMaximum :: [Integer] -> Integer #-}
 
 -- | 'minimum' returns the minimum value from a list,
 -- which must be non-empty, finite, and of an ordered type.
@@ -433,6 +435,8 @@ minimum xs              =  foldl1 min xs
 strictMinimum           :: (Ord a) => [a] -> a
 strictMinimum []        =  errorEmptyList "minimum"
 strictMinimum xs        =  foldl1' min xs
+{-# SPECIALIZE  strictMinimum :: [Int] -> Int #-}
+{-# SPECIALIZE  strictMinimum :: [Integer] -> Integer #-}
 
 
 -- | 'iterate' @f x@ returns an infinite list of repeated applications



More information about the ghc-commits mailing list