diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-04-08 15:04:34 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-29 17:26:43 -0400 |
commit | 7bb3443a4fe8acfaa3fec34f58c91173f737777d (patch) | |
tree | fbdbcad4a19e1c257c00c8f73cf042dc6196b9df | |
parent | c308c9af2e1345f6a2adece971cf7ffed78a31a9 (diff) | |
download | haskell-7bb3443a4fe8acfaa3fec34f58c91173f737777d.tar.gz |
Fix inlining of division wrappers
-rw-r--r-- | libraries/base/GHC/Real.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libraries/base/GHC/Real.hs b/libraries/base/GHC/Real.hs index 696cb8a52e..3fb13af822 100644 --- a/libraries/base/GHC/Real.hs +++ b/libraries/base/GHC/Real.hs @@ -326,34 +326,40 @@ instance Real Int where instance Integral Int where toInteger (I# i) = IS i + {-# INLINE quot #-} -- see Note [INLINE division wrappers] in GHC.Base a `quot` b | b == 0 = divZeroError | b == (-1) && a == minBound = overflowError -- Note [Order of tests] -- in GHC.Int | otherwise = a `quotInt` b + {-# INLINE rem #-} -- see Note [INLINE division wrappers] in GHC.Base !a `rem` b -- See Note [Special case of mod and rem is lazy] | b == 0 = divZeroError | b == (-1) = 0 | otherwise = a `remInt` b + {-# INLINE div #-} -- see Note [INLINE division wrappers] in GHC.Base a `div` b | b == 0 = divZeroError | b == (-1) && a == minBound = overflowError -- Note [Order of tests] -- in GHC.Int | otherwise = a `divInt` b + {-# INLINE mod #-} -- see Note [INLINE division wrappers] in GHC.Base !a `mod` b -- See Note [Special case of mod and rem is lazy] | b == 0 = divZeroError | b == (-1) = 0 | otherwise = a `modInt` b + {-# INLINE quotRem #-} -- see Note [INLINE division wrappers] in GHC.Base a `quotRem` b | b == 0 = divZeroError -- Note [Order of tests] in GHC.Int | b == (-1) && a == minBound = (overflowError, 0) | otherwise = a `quotRemInt` b + {-# INLINE divMod #-} -- see Note [INLINE division wrappers] in GHC.Base a `divMod` b | b == 0 = divZeroError -- Note [Order of tests] in GHC.Int @@ -379,26 +385,38 @@ instance Real Word where -- | @since 2.01 instance Integral Word where + {-# INLINE quot #-} -- see Note [INLINE division wrappers] in GHC.Base quot (W# x#) y@(W# y#) | y /= 0 = W# (x# `quotWord#` y#) | otherwise = divZeroError + + {-# INLINE rem #-} -- see Note [INLINE division wrappers] in GHC.Base rem (W# x#) y@(W# y#) | y /= 0 = W# (x# `remWord#` y#) | otherwise = divZeroError + + {-# INLINE div #-} -- see Note [INLINE division wrappers] in GHC.Base div (W# x#) y@(W# y#) | y /= 0 = W# (x# `quotWord#` y#) | otherwise = divZeroError + + {-# INLINE mod #-} -- see Note [INLINE division wrappers] in GHC.Base mod (W# x#) y@(W# y#) | y /= 0 = W# (x# `remWord#` y#) | otherwise = divZeroError + + {-# INLINE quotRem #-} -- see Note [INLINE division wrappers] in GHC.Base quotRem (W# x#) y@(W# y#) | y /= 0 = case x# `quotRemWord#` y# of (# q, r #) -> (W# q, W# r) | otherwise = divZeroError + + {-# INLINE divMod #-} -- see Note [INLINE division wrappers] in GHC.Base divMod (W# x#) y@(W# y#) | y /= 0 = (W# (x# `quotWord#` y#), W# (x# `remWord#` y#)) | otherwise = divZeroError + toInteger (W# x#) = integerFromWord# x# -------------------------------------------------------------- |