summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-01-27 11:50:12 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-28 06:10:38 -0500
commitc3ff35bbd11fd213ec2773bc0a03e2533fda7c1a (patch)
tree004cb12e93dfde754f314fd66cf888b6b03bbfd8 /libraries
parent035d983dfa217bf8784b86e78d6024a3ca1a3f4f (diff)
downloadhaskell-c3ff35bbd11fd213ec2773bc0a03e2533fda7c1a.tar.gz
Mark divModInt and friends as INLINE (#19267)
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
Diffstat (limited to 'libraries')
-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