[commit: ghc] master: Get eqTypeRep to inline (8529fbb)
git at git.haskell.org
git at git.haskell.org
Thu Feb 15 08:50:23 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/8529fbba309cd692bbbb0386321515d05a6ed256/ghc
>---------------------------------------------------------------
commit 8529fbba309cd692bbbb0386321515d05a6ed256
Author: David Feuer <david.feuer at gmail.com>
Date: Thu Feb 15 03:48:51 2018 -0500
Get eqTypeRep to inline
GHC didn't inline `eqTypeRep`, presumably because it ended up
being too big. This was unfortunate because it produces a
`Maybe`, which will almost always be scrutinized immediately.
Split `eqTypeRep` into a worker and a tiny wrapper, and mark the
wrapper `INLINABLE`. This change actually seems to reduce Core size,
at least in a small test.
Reviewers: hvr, bgamari, mpickering
Reviewed By: mpickering
Subscribers: mpickering, rwbarton, thomie, carter
GHC Trac Issues: #14790
Differential Revision: https://phabricator.haskell.org/D4405
>---------------------------------------------------------------
8529fbba309cd692bbbb0386321515d05a6ed256
libraries/base/Data/Typeable/Internal.hs | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index a01a9ff..6c52cc5 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -564,9 +564,17 @@ typeRepTyCon (TrFun {}) = typeRepTyCon $ typeRep @(->)
eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -> TypeRep b -> Maybe (a :~~: b)
eqTypeRep a b
- | typeRepFingerprint a == typeRepFingerprint b = Just (unsafeCoerce HRefl)
- | otherwise = Nothing
-
+ | sameTypeRep a b = Just (unsafeCoerce# HRefl)
+ | otherwise = Nothing
+-- We want GHC to inline eqTypeRep to get rid of the Maybe
+-- in the usual case that it is scrutinized immediately. We
+-- split eqTypeRep into a worker and wrapper because otherwise
+-- it's much larger than anything we'd want to inline.
+{-# INLINABLE eqTypeRep #-}
+
+sameTypeRep :: forall k1 k2 (a :: k1) (b :: k2).
+ TypeRep a -> TypeRep b -> Bool
+sameTypeRep a b = typeRepFingerprint a == typeRepFingerprint b
-------------------------------------------------------------
--
More information about the ghc-commits
mailing list