[commit: ghc] master: Allow enumDeltaIntegerFB to be inlined (78053f4)
git at git.haskell.org
git at git.haskell.org
Mon Sep 28 12:55:26 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/78053f449d47a90c977ec3a893524f2cdb5d33f9/ghc
>---------------------------------------------------------------
commit 78053f449d47a90c977ec3a893524f2cdb5d33f9
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Mon Sep 28 13:48:40 2015 +0200
Allow enumDeltaIntegerFB to be inlined
The function is very small and the compiler should be at liberty to
inline it. But it is recursive, so it did not do it before. By applying
the usual transformation with a local recursive function, GHC can now
inline it, producing the loop that one would expect.
>---------------------------------------------------------------
78053f449d47a90c977ec3a893524f2cdb5d33f9
libraries/base/GHC/Enum.hs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libraries/base/GHC/Enum.hs b/libraries/base/GHC/Enum.hs
index a11d4f8..0d91cc7 100644
--- a/libraries/base/GHC/Enum.hs
+++ b/libraries/base/GHC/Enum.hs
@@ -704,7 +704,8 @@ the special case varies more from the general case, due to the issue of overflow
{-# NOINLINE [0] enumDeltaIntegerFB #-}
enumDeltaIntegerFB :: (Integer -> b -> b) -> Integer -> Integer -> b
-enumDeltaIntegerFB c x d = x `seq` (x `c` enumDeltaIntegerFB c (x+d) d)
+enumDeltaIntegerFB c x d = go x
+ where go x = x `seq` (x `c` go (x+d))
{-# NOINLINE [1] enumDeltaInteger #-}
enumDeltaInteger :: Integer -> Integer -> [Integer]
More information about the ghc-commits
mailing list