summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Feuer <david.feuer@gmail.com>2018-02-15 03:48:51 -0500
committerDavid Feuer <David.Feuer@gmail.com>2018-02-15 03:48:52 -0500
commit8529fbba309cd692bbbb0386321515d05a6ed256 (patch)
tree158c9c35333de950160fd7484eedaa2c1bcf9a25
parent0c2350c293b82e4cb24a66e00b904933bdb1c8f3 (diff)
downloadhaskell-8529fbba309cd692bbbb0386321515d05a6ed256.tar.gz
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
-rw-r--r--libraries/base/Data/Typeable/Internal.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index a01a9ff859..6c52cc5dd1 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
-------------------------------------------------------------
--