summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-01-27 11:50:12 +0100
committerSebastian Graf <sgraf1337@gmail.com>2021-02-27 11:42:42 -0500
commit69f0b1df8702a579c116b2ab77154bd2ac31a08b (patch)
treeda261d359ea563fbc1b6f80e2428a0ea204c1b47
parent157fe938eabf6428fa9de42d57f8cfad08b38ddb (diff)
downloadhaskell-wip/T19267.tar.gz
Mark divModInt and friends as INLINE (#19267)wip/T19267
So that we don't get a silly worker `$wdivModInt` and risk inlining `divModInt#` into `divModInt` or `$wdivModInt`, making both unlikely to inline at call sites. Fixes #19267. There's a spurious metric decrease (was an *increase*) in T12545. That seems entirely due to shifts in Unique distribution (+5% more `IntMap.$winsert` calls). The inappropriateness of the acceptance window is tracked in #19414. Metric Decrease: T12545 Metric Increase: T12545
-rw-r--r--libraries/base/GHC/Base.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index d21226c7c4..e691c558bf 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -1596,8 +1596,13 @@ getTag x = dataToTag# x
-- Definitions of the boxed PrimOps; these will be
-- used in the case of partial applications, etc.
+-- See Note [INLINE division wrappers]
{-# INLINE quotInt #-}
{-# INLINE remInt #-}
+{-# INLINE divInt #-}
+{-# INLINE modInt #-}
+{-# INLINE quotRemInt #-}
+{-# INLINE divModInt #-}
quotInt, remInt, divInt, modInt :: Int -> Int -> Int
(I# x) `quotInt` (I# y) = I# (x `quotInt#` y)
@@ -1625,6 +1630,17 @@ x# `divModInt#` y#
| otherwise =
x# `quotRemInt#` y#
+{- Note [INLINE division wrappers]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The Int division functions such as 'quotRemInt' and 'divModInt' have
+been manually worker/wrappered, presumably because they construct
+*nested* products.
+We intend to preserve the exact worker/wrapper split, hence we mark
+the wrappers INLINE (#19267). That makes sure the optimiser doesn't
+accidentally inline the worker into the wrapper, undoing the manual
+split again.
+-}
+
-- Wrappers for the shift operations. The uncheckedShift# family are
-- undefined when the amount being shifted by is greater than the size
-- in bits of Int#, so these wrappers perform a check and return