summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2022-12-05 12:18:47 +0100
committerSebastian Graf <sebastian.graf@kit.edu>2022-12-13 10:24:46 +0100
commitdc021331f99ee4b3e699350312f0aef27f4c6a47 (patch)
tree0f3e6254317908a3668a1667bf6c6de23ebec55b /compiler
parent1b10aad17e85fa9a44bc4c72e536686421b1d6b4 (diff)
downloadhaskell-wip/T22317.tar.gz
Fix warnings in ExactPrint (#22555)wip/T22317
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Core/Unfold.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/GHC/Core/Unfold.hs b/compiler/GHC/Core/Unfold.hs
index a6ec0b321e..96c1a07ffa 100644
--- a/compiler/GHC/Core/Unfold.hs
+++ b/compiler/GHC/Core/Unfold.hs
@@ -698,19 +698,24 @@ funSize opts top_args fun n_val_args voids
conSize :: DataCon -> Int -> ExprSize
conSize dc n_val_args
- | n_val_args == 0 = SizeIs 0 emptyBag 10 -- Like variables
-
-- See Note [Unboxed tuple size and result discount]
| isUnboxedTupleDataCon dc = SizeIs 0 emptyBag 10
-- See Note [Constructor size and result discount]
- | otherwise = SizeIs (callSize n_val_args 0) emptyBag 10
+ | otherwise = SizeIs (6 * n_val_args) emptyBag 10
{- Note [Constructor size and result discount]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We generally compute the size of a constructor application as if it was
-a regular function call (#22317); the size of the code we generate is similar.
-We have an extra case for when it's a nullary application, in which case it is
+Constructor applications are generally a bit smaller than function calls, but
+we have to ensure that we don't duplicate a lot of big record updates.
+So every value argument contributes a size of 6, but SG's experiments concluded
+that any factor between 6 and 9 would work:
+ * A factor of 10 means we don't inline eftWord anymore (undesirable for
+ T15263)
+ * But a factor of 5 means we get too much inlining in T22317b.
+Picking 6 seems to have the lowest potential for breaking performance changes,
+so that's what we go with.
+A side effect of the formula is that a nullary constructor application is
treated the same as a lone variable.
The "result discount" is applied if the result of the call is