[Git][ghc/ghc][wip/T22317] 2 commits: Simplifier: Fix `conSize` estimate (#22317)

Sebastian Graf (@sgraf812) gitlab at gitlab.haskell.org
Tue Dec 13 09:25:10 UTC 2022



Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC


Commits:
1b10aad1 by Sebastian Graf at 2022-12-13T10:20:50+01:00
Simplifier: Fix `conSize` estimate (#22317)

The estimate we used to have was far too optimistic (#22317).
We now size up constructor applications like we do function applications.
See the changes to `Note [Constructor size and result discount]`.

I also changed `Note [Inlining small things to avoid creating a thunk]` so that
it is clear that "thing" includes join points.

NoFib results:
```
--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
           atom          +0.0%     -2.3%
      cacheprof          -0.0%     -3.0%
       calendar          +1.1%     +1.1%
       cichelli           0.0%     -0.5%
  comp_lab_zift          +0.8%     +0.5%
         dom-lt          +0.6%     +0.4%
          fasta          +0.0%     -0.4%
       fibheaps          -1.3%     -1.8%
         gamteb          -2.4%     -1.4%
         hidden          +0.0%     -0.9%
     last-piece          -1.5%     -2.4%
           life          +2.1%     +1.0%
         linear           0.0%     -1.8%
           para          -2.8%     -1.7%
            pic           0.0%     -0.6%
          solid          -4.0%     -1.2%
         sphere           0.0%     -1.0%
      transform          +0.0%     -0.8%
      wave4main          +0.8%     +0.2%
--------------------------------------------------------------------------------
            Min          -4.0%     -3.0%
            Max          +2.1%     +1.1%
 Geometric Mean          -0.1%     -0.2%
```
Binary sizes go down by 0.1%, ever so slightly.

Fixes #22317. Regression test in T22317b.

- - - - -
dc021331 by Sebastian Graf at 2022-12-13T10:24:46+01:00
Fix warnings in ExactPrint (#22555)

- - - - -


22 changed files:

- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Unfold.hs
- testsuite/tests/deSugar/should_compile/T13208.stdout
- testsuite/tests/deSugar/should_compile/T16615.stderr
- testsuite/tests/numeric/should_compile/T14170.stdout
- testsuite/tests/numeric/should_compile/T14465.stdout
- testsuite/tests/numeric/should_compile/T7116.stdout
- testsuite/tests/simplCore/should_compile/T13143.stderr
- testsuite/tests/simplCore/should_compile/T18013.stderr
- + testsuite/tests/simplCore/should_compile/T22317b.hs
- + testsuite/tests/simplCore/should_compile/T22317b.stderr
- testsuite/tests/simplCore/should_compile/T3717.stderr
- testsuite/tests/simplCore/should_compile/T3772.stdout
- testsuite/tests/simplCore/should_compile/T4908.stderr
- testsuite/tests/simplCore/should_compile/T4930.stderr
- testsuite/tests/simplCore/should_compile/T7360.stderr
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/simplCore/should_compile/spec-inline.stderr
- testsuite/tests/stranal/should_compile/T20510.stderr
- testsuite/tests/stranal/should_compile/T21128.stderr
- testsuite/tests/typecheck/should_compile/T13032.stderr
- utils/check-exact/ExactPrint.hs


Changes:

=====================================
compiler/GHC/Core/Opt/Simplify/Utils.hs
=====================================
@@ -1550,10 +1550,12 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs
   = case occ_info of
       OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br }
         -- See Note [Inline small things to avoid creating a thunk]
+        --- | BC_Let{} <- bind_cxt -- No! "thing" also includes join points
+                                   -- See the Note.
 
-        -> n_br < 100  -- See Note [Suppress exponential blowup]
+        | n_br < 100  -- See Note [Suppress exponential blowup]
 
-           && smallEnoughToInline uf_opts unfolding     -- Small enough to dup
+        , smallEnoughToInline uf_opts unfolding     -- Small enough to dup
                         -- ToDo: consider discount on smallEnoughToInline if int_cxt is true
                         --
                         -- NB: Do NOT inline arbitrarily big things, even if occ_n_br=1
@@ -1564,7 +1566,7 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs
                         -- PRINCIPLE: when we've already simplified an expression once,
                         -- make sure that we only inline it if it's reasonably small.
 
-           && (in_lam == NotInsideLam ||
+        , in_lam == NotInsideLam ||
                         -- Outside a lambda, we want to be reasonably aggressive
                         -- about inlining into multiple branches of case
                         -- e.g. let x = <non-value>
@@ -1573,10 +1575,11 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs
                         -- the uses in C1, C2 are not 'interesting'
                         -- An example that gets worse if you add int_cxt here is 'clausify'
 
-                (isCheapUnfolding unfolding && int_cxt == IsInteresting))
+                (isCheapUnfolding unfolding && int_cxt == IsInteresting)
                         -- isCheap => acceptable work duplication; in_lam may be true
                         -- int_cxt to prevent us inlining inside a lambda without some
                         -- good reason.  See the notes on int_cxt in preInlineUnconditionally
+        -> True
 
       IAmDead -> True   -- This happens; for example, the case_bndr during case of
                         -- known constructor:  case (a,b) of x { (p,q) -> ... }
@@ -1610,17 +1613,39 @@ The point of examining occ_info here is that for *non-values* that
 occur outside a lambda, the call-site inliner won't have a chance
 (because it doesn't know that the thing only occurs once).  The
 pre-inliner won't have gotten it either, if the thing occurs in more
-than one branch So the main target is things like
-
-     let x = f y in
-     case v of
-        True  -> case x of ...
-        False -> case x of ...
-
-This is very important in practice; e.g. wheel-seive1 doubles
-in allocation if you miss this out.  And bits of GHC itself start
-to allocate more.  An egregious example is test perf/compiler/T14697,
-where GHC.Driver.CmdLine.$wprocessArgs allocated hugely more.
+than one branch. So the main target is things like $ssieve from wheel-sieve1
+
+   let ds1 = <huge> in
+   let ds2 = case x of I# x# -> case y of I# y# -> I# (x# +# y#) in
+   join $j = ds2 : ds1 in
+   if z > 2
+     then jump $j
+     else if $wnotDivBy ... (unI# ds2) ...
+            then ds1
+            else jump $j
+
+Here, we want to inline the small join point $j. By itself, that is not an
+improvement, but after inlining, we see that `ds1` and `ds2` become OneOcc, too:
+
+   let ds1 = <huge> in
+   let ds2 = case x of I# x# -> case y of I# y# -> I# (x# +# y#) in
+   if z > 2
+     then ds2 : ds1
+     else if $wnotDivBy ... <strict context>(unI# ds2) ...
+            then ds1
+            else ds2 : ds1
+
+And now we can inline `ds1` and `ds2`. The latter can even be unboxed in the hot
+path when z <= 2!
+
+So by inlining the join point, we have greatly improved clarity for occurrence
+analysis. This is very important in practice; e.g. wheel-sieve1 doubles
+in allocation if you miss this out. And bits of GHC itself start to
+allocate more. An egregious example is test perf/compiler/T14697, where
+GHC.Driver.CmdLine.$wprocessArgs allocated hugely more.
+
+Ideally, occurrence analysis would simply look through $j without the Simplifier
+needing to inline $j; that's discussed in #22404.
 
 Note [Suppress exponential blowup]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


=====================================
compiler/GHC/Core/Unfold.hs
=====================================
@@ -669,7 +669,7 @@ jumpSize n_val_args voids = 2 * (1 + n_val_args - voids)
   -- better solution?
 
 funSize :: UnfoldingOpts -> [Id] -> Id -> Int -> Int -> ExprSize
--- Size for functions that are not constructors or primops
+-- Size for function calls that are not constructors or primops
 -- Note [Function applications]
 funSize opts top_args fun n_val_args voids
   | fun `hasKey` buildIdKey   = buildSize
@@ -698,21 +698,25 @@ 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 10 emptyBag 10
+  | otherwise = SizeIs (6 * n_val_args) emptyBag 10
 
 {- Note [Constructor size and result discount]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Treat a constructors application as size 10, regardless of how many
-arguments it has; we are keen to expose them (and we charge separately
-for their args).  We can't treat them as size zero, else we find that
-(Just x) has size 0, which is the same as a lone variable; and hence
-'v' will always be replaced by (Just x), where v is bound to Just x.
+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
 scrutinised (say by a case).  For a constructor application that will
@@ -744,6 +748,14 @@ win", but its terribly dangerous because a function with many many
 case branches, each finishing with a constructor, can have an
 arbitrarily large discount.  This led to terrible code bloat: see #6099.
 
+Historical note 3: Until Dec 22 we used to give all DataCon apps had size 10.
+(We can't treat them as size zero, else we find that (Just x) has size 0,
+which is the same as a lone variable; and hence 'v' will always be replaced by
+(Just x), where v is bound to Just x.)
+But constant size 10 turned out to cause unnecessary code bloat in #22317
+(T22317b). The higher the number of fields, the more code we generate for each
+DataCon app, so we should really treat a DataCon app more like a function app.
+
 Note [Unboxed tuple size and result discount]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 However, unboxed tuples count as size zero. I found occasions where we had


=====================================
testsuite/tests/deSugar/should_compile/T13208.stdout
=====================================
@@ -3,4 +3,4 @@
          Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
 f = \ (@p) _ [Occ=Dead] -> GHC.Types.True
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}]


=====================================
testsuite/tests/deSugar/should_compile/T16615.stderr
=====================================
@@ -7,7 +7,7 @@ Result size of Desugar (after optimization)
 T16615.$trModule :: GHC.Types.Module
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}]
 T16615.$trModule
   = GHC.Types.Module
       (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T16615"#)
@@ -17,7 +17,7 @@ Rec {
 g :: Int -> Bool
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 130 10}]
 g = \ (i :: Int) ->
       case == @Int GHC.Classes.$fEqInt i (GHC.Types.I# 0#) of {
         False -> f (pred @Int GHC.Enum.$fEnumInt i);
@@ -28,7 +28,7 @@ g = \ (i :: Int) ->
 f [Occ=LoopBreaker] :: Int -> Bool
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 130 10}]
 f = \ (i :: Int) ->
       case == @Int GHC.Classes.$fEqInt i (GHC.Types.I# 0#) of {
         False -> g (pred @Int GHC.Enum.$fEnumInt i);


=====================================
testsuite/tests/numeric/should_compile/T14170.stdout
=====================================
@@ -14,7 +14,7 @@ NatVal.$trModule4 = "main"#
 NatVal.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ NatVal.$trModule2 = "NatVal"#
 NatVal.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 NatVal.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 NatVal.$trModule
   = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1
 
@@ -43,7 +43,7 @@ NatVal.$trModule
 foo :: Integer
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 foo = GHC.Num.Integer.IS 0#
 
 


=====================================
testsuite/tests/numeric/should_compile/T14465.stdout
=====================================
@@ -7,7 +7,7 @@ Result size of Tidy Core
 ten :: Natural
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 ten = GHC.Num.Natural.NS 10##
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -21,7 +21,7 @@ M.$trModule4 = "main"#
 M.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 M.$trModule3 = GHC.Types.TrNameS M.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -35,14 +35,14 @@ M.$trModule2 = "M"#
 M.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 M.$trModule1 = GHC.Types.TrNameS M.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 M.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1
 
 -- RHS size: {terms: 1, types: 1, coercions: 0, joins: 0/0}
@@ -59,14 +59,14 @@ minusOne = GHC.Prim.Exception.raiseUnderflow @Natural
 twoTimesTwo :: Natural
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 twoTimesTwo = GHC.Num.Natural.NS 4##
 
 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
 M.one1 :: Natural
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 M.one1 = GHC.Num.Natural.NS 1##
 
 -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0}


=====================================
testsuite/tests/numeric/should_compile/T7116.stdout
=====================================
@@ -14,7 +14,7 @@ T7116.$trModule4 = "main"#
 T7116.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ T7116.$trModule2 = "T7116"#
 T7116.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T7116.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T7116.$trModule
   = GHC.Types.Module T7116.$trModule3 T7116.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T13143.stderr
=====================================
@@ -34,7 +34,7 @@ T13143.$trModule4 = "main"#
 T13143.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -48,14 +48,14 @@ T13143.$trModule2 = "T13143"#
 T13143.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T13143.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T13143.$trModule
   = GHC.Types.Module T13143.$trModule3 T13143.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T18013.stderr
=====================================
@@ -131,65 +131,30 @@ Rule fired: Class op fmap (BUILTIN)
 
 ==================== Tidy Core ====================
 Result size of Tidy Core
-  = {terms: 52, types: 95, coercions: 17, joins: 0/1}
+  = {terms: 64, types: 125, coercions: 17, joins: 0/1}
 
--- RHS size: {terms: 37, types: 78, coercions: 17, joins: 0/1}
-mapMaybeRule [InlPrag=[2]]
-  :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b)
-[GblId,
- Arity=1,
- Str=<1!P(L,LC(S,C(1,C(1,P(L,1L)))))>,
- Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True,
-         Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
-         Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) ->
-                 case f of { Rule @s ww ww1 [Occ=OnceL1!] ->
-                 T18013a.Rule
-                   @IO
-                   @(Maybe a)
-                   @(Maybe b)
-                   @s
-                   ww
-                   ((\ (s2 [Occ=Once1] :: s)
-                       (a1 [Occ=Once1!] :: Maybe a)
-                       (s1 [Occ=Once2] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
-                       case a1 of {
-                         Nothing ->
-                           (# s1, T18013a.Result @s @(Maybe b) ww (GHC.Maybe.Nothing @b) #);
-                         Just x [Occ=Once1] ->
-                           case ((ww1 s2 x)
-                                 `cast` <Co:4> :: IO (Result s b)
-                                                  ~R# (GHC.Prim.State# GHC.Prim.RealWorld
-                                                       -> (# GHC.Prim.State# GHC.Prim.RealWorld,
-                                                             Result s b #)))
-                                  s1
-                           of
-                           { (# ipv [Occ=Once1], ipv1 [Occ=Once1!] #) ->
-                           case ipv1 of { Result t2 [Occ=Once1] c1 [Occ=Once1] ->
-                           (# ipv, T18013a.Result @s @(Maybe b) t2 (GHC.Maybe.Just @b c1) #)
-                           }
-                           }
-                       })
-                    `cast` <Co:13> :: (s
-                                       -> Maybe a
-                                       -> GHC.Prim.State# GHC.Prim.RealWorld
-                                       -> (# GHC.Prim.State# GHC.Prim.RealWorld,
-                                             Result s (Maybe b) #))
-                                      ~R# (s -> Maybe a -> IO (Result s (Maybe b))))
-                 }}]
-mapMaybeRule
-  = \ (@a) (@b) (f :: Rule IO a b) ->
-      case f of { Rule @s ww ww1 ->
+-- RHS size: {terms: 39, types: 71, coercions: 17, joins: 0/1}
+T18013.$wmapMaybeRule [InlPrag=[2]]
+  :: forall {a} {b} {s}.
+     s -> (s -> a -> IO (Result s b)) -> Rule IO (Maybe a) (Maybe b)
+[GblId[StrictWorker([!])],
+ Arity=2,
+ Str=<1L><LC(S,C(1,C(1,P(L,1L))))>,
+ Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 60] 220 10}]
+T18013.$wmapMaybeRule
+  = \ (@a) (@b) (@s) (ww :: s) (ww1 :: s -> a -> IO (Result s b)) ->
+      case ww of ww2 { __DEFAULT ->
       let {
         lvl :: Result s (Maybe b)
         [LclId, Unf=OtherCon []]
-        lvl = T18013a.Result @s @(Maybe b) ww (GHC.Maybe.Nothing @b) } in
+        lvl = T18013a.Result @s @(Maybe b) ww2 (GHC.Maybe.Nothing @b) } in
       T18013a.Rule
         @IO
         @(Maybe a)
         @(Maybe b)
         @s
-        ww
+        ww2
         ((\ (s2 :: s)
             (a1 :: Maybe a)
             (s1 :: GHC.Prim.State# GHC.Prim.RealWorld) ->
@@ -216,6 +181,25 @@ mapMaybeRule
                            ~R# (s -> Maybe a -> IO (Result s (Maybe b))))
       }
 
+-- RHS size: {terms: 9, types: 21, coercions: 0, joins: 0/0}
+mapMaybeRule [InlPrag=[2]]
+  :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b)
+[GblId,
+ Arity=1,
+ Str=<1!P(1L,LC(S,C(1,C(1,P(L,1L)))))>,
+ Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True,
+         WorkFree=True, Expandable=True,
+         Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
+         Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) ->
+                 case f of { Rule @s ww [Occ=Once1] ww1 [Occ=Once1] ->
+                 T18013.$wmapMaybeRule @a @b @s ww ww1
+                 }}]
+mapMaybeRule
+  = \ (@a) (@b) (f :: Rule IO a b) ->
+      case f of { Rule @s ww ww1 ->
+      T18013.$wmapMaybeRule @a @b @s ww ww1
+      }
+
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
 T18013.$trModule4 :: GHC.Prim.Addr#
 [GblId,
@@ -227,7 +211,7 @@ T18013.$trModule4 = "main"#
 T18013.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T18013.$trModule3 = GHC.Types.TrNameS T18013.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -241,14 +225,14 @@ T18013.$trModule2 = "T18013"#
 T18013.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T18013.$trModule1 = GHC.Types.TrNameS T18013.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T18013.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T18013.$trModule
   = GHC.Types.Module T18013.$trModule3 T18013.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T22317b.hs
=====================================
@@ -0,0 +1,22 @@
+{-# LANGUAGE BangPatterns #-}
+
+module T22317b where
+
+import GHC.Exts
+
+data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool)
+
+
+m :: Maybe a -> Maybe a -> Maybe a
+m (Just v1) Nothing = Just v1
+m _         mb      = mb
+{-# INLINE m #-}
+
+f :: T -> T -> T
+f (T a1 b1 c1 d1) (T a2 b2 c2 d2)
+  = let j1 !a = let j2 !b = let j3 !c = let j4 !d = T a b c d
+                                        in j4 (inline m d1 d2)
+                            in j3 (inline m c1 c2)
+                in j2 (inline m b1 b2)
+    in j1 (inline m a1 a2)
+{-# OPAQUE f #-}


=====================================
testsuite/tests/simplCore/should_compile/T22317b.stderr
=====================================
@@ -0,0 +1,825 @@
+Considering inlining: $j_sEl
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 60 10
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 20
+  ANSWER = YES
+Considering inlining: $j_sEl
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 60 10
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 20
+  ANSWER = YES
+Considering inlining: $j_sEl
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 60 10
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 20
+  ANSWER = YES
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 290 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 250
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 290 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 250
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 290 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 250
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 382 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 342
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 382 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 342
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 382 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 342
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 474 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 434
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 474 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 434
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 474 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 434
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 322 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 282
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 414 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 210
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 312 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 292
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 312 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 272
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 312 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 272
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 394 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 394 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 354
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 394 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 354
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 210
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 230 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 312 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 292
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 312 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 272
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 312 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 272
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 394 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 374
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 394 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 354
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 394 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 354
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 210 30
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 190
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 210 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 170
+  ANSWER = NO
+Considering inlining: $j_sEm
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 210 30
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 170
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 272 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 252
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 272 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 232
+  ANSWER = NO
+Considering inlining: $j_sEn
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 272 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 232
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [TrivArg]
+  interesting continuation BoringCtxt
+  some_benefit False
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 334 0
+  case depth = 1
+  depth based penalty = 0
+  discounted size = 314
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 334 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 294
+  ANSWER = NO
+Considering inlining: $j_sEo
+  arg infos [ValueArg]
+  interesting continuation BoringCtxt
+  some_benefit True
+  is exp: True
+  is work-free: True
+  guidance IF_ARGS [20] 334 0
+  case depth = 2
+  depth based penalty = 0
+  discounted size = 294
+  ANSWER = NO


=====================================
testsuite/tests/simplCore/should_compile/T3717.stderr
=====================================
@@ -14,7 +14,7 @@ T3717.$trModule4 = "main"#
 T3717.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T3717.$trModule3 = GHC.Types.TrNameS T3717.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ T3717.$trModule2 = "T3717"#
 T3717.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T3717.$trModule1 = GHC.Types.TrNameS T3717.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T3717.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T3717.$trModule
   = GHC.Types.Module T3717.$trModule3 T3717.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T3772.stdout
=====================================
@@ -14,7 +14,7 @@ T3772.$trModule4 = "main"#
 T3772.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ T3772.$trModule2 = "T3772"#
 T3772.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T3772.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T3772.$trModule
   = GHC.Types.Module T3772.$trModule3 T3772.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T4908.stderr
=====================================
@@ -14,7 +14,7 @@ T4908.$trModule4 = "main"#
 T4908.$trModule3 :: TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T4908.$trModule3 = GHC.Types.TrNameS T4908.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ T4908.$trModule2 = "T4908"#
 T4908.$trModule1 :: TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T4908.$trModule1 = GHC.Types.TrNameS T4908.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T4908.$trModule :: Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T4908.$trModule
   = GHC.Types.Module T4908.$trModule3 T4908.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T4930.stderr
=====================================
@@ -14,7 +14,7 @@ T4930.$trModule4 = "main"#
 T4930.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T4930.$trModule3 = GHC.Types.TrNameS T4930.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ T4930.$trModule2 = "T4930"#
 T4930.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T4930.$trModule1 = GHC.Types.TrNameS T4930.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T4930.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T4930.$trModule
   = GHC.Types.Module T4930.$trModule3 T4930.$trModule1
 


=====================================
testsuite/tests/simplCore/should_compile/T7360.stderr
=====================================
@@ -80,7 +80,7 @@ T7360.$trModule4 = "main"#
 T7360.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7360.$trModule3 = GHC.Types.TrNameS T7360.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -94,14 +94,14 @@ T7360.$trModule2 = "T7360"#
 T7360.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7360.$trModule1 = GHC.Types.TrNameS T7360.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T7360.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T7360.$trModule
   = GHC.Types.Module T7360.$trModule3 T7360.$trModule1
 
@@ -123,14 +123,14 @@ T7360.$tcFoo2 = "Foo"#
 T7360.$tcFoo1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7360.$tcFoo1 = GHC.Types.TrNameS T7360.$tcFoo2
 
 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
 T7360.$tcFoo :: GHC.Types.TyCon
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}]
 T7360.$tcFoo
   = GHC.Types.TyCon
       1581370841583180512#Word64
@@ -158,14 +158,14 @@ T7360.$tc'Foo6 = "'Foo1"#
 T7360.$tc'Foo5 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7360.$tc'Foo5 = GHC.Types.TrNameS T7360.$tc'Foo6
 
 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
 T7360.$tc'Foo1 :: GHC.Types.TyCon
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}]
 T7360.$tc'Foo1
   = GHC.Types.TyCon
       3986951253261644518#Word64
@@ -186,14 +186,14 @@ T7360.$tc'Foo8 = "'Foo2"#
 T7360.$tc'Foo7 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7360.$tc'Foo7 = GHC.Types.TrNameS T7360.$tc'Foo8
 
 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
 T7360.$tc'Foo2 :: GHC.Types.TyCon
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}]
 T7360.$tc'Foo2
   = GHC.Types.TyCon
       17325079864060690428#Word64
@@ -219,14 +219,14 @@ T7360.$tc'Foo11 = "'Foo3"#
 T7360.$tc'Foo10 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 T7360.$tc'Foo10 = GHC.Types.TrNameS T7360.$tc'Foo11
 
 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
 T7360.$tc'Foo3 :: GHC.Types.TyCon
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}]
 T7360.$tc'Foo3
   = GHC.Types.TyCon
       3674231676522181654#Word64


=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -453,6 +453,10 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab
 test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques'])
 # Should not inline m, so there shouldn't be a single YES
 test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output'])
+# Should not inline *any* join point, but after #22317 we still fail to come up
+# with a good argument discount for the inner-most join point and hence inline it.
+# It's important that we don't inline more, though! So 3 times YES is expected, but not more often
+test('T22317b', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check \$j -ddebug-output'])
 
 test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques'])
 test('T22491', normal, compile, ['-O2'])


=====================================
testsuite/tests/simplCore/should_compile/spec-inline.stderr
=====================================
@@ -14,7 +14,7 @@ Roman.$trModule4 = "main"#
 Roman.$trModule3 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 Roman.$trModule3 = GHC.Types.TrNameS Roman.$trModule4
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -28,14 +28,14 @@ Roman.$trModule2 = "Roman"#
 Roman.$trModule1 :: GHC.Types.TrName
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 Roman.$trModule1 = GHC.Types.TrNameS Roman.$trModule2
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 Roman.$trModule :: GHC.Types.Module
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 Roman.$trModule
   = GHC.Types.Module Roman.$trModule3 Roman.$trModule1
 
@@ -129,14 +129,14 @@ Roman.foo_go
 Roman.foo2 :: Int
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 Roman.foo2 = GHC.Types.I# 6#
 
 -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0}
 Roman.foo1 :: Maybe Int
 [GblId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2
 
 -- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0}


=====================================
testsuite/tests/stranal/should_compile/T20510.stderr
=====================================
@@ -1,90 +1,55 @@
 
 ==================== Exitification transformation ====================
 Result size of Exitification transformation
-  = {terms: 50, types: 22, coercions: 0, joins: 2/2}
+  = {terms: 51, types: 23, coercions: 0, joins: 2/2}
 
--- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
-lvl :: Int
-[LclId,
- Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
-lvl = GHC.Types.I# 0#
-
--- RHS size: {terms: 32, types: 14, coercions: 0, joins: 2/2}
-small :: Int -> Int
-[LclIdX,
+-- RHS size: {terms: 25, types: 10, coercions: 0, joins: 2/2}
+$wsmall [InlPrag=[2]] :: GHC.Prim.Int# -> GHC.Prim.Int#
+[LclId[StrictWorker([])],
  Arity=1,
- Str=<SP(SL)>,
- Cpr=1,
- Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True,
-         Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
-         Tmpl= \ (x [Dmd=SP(SL)] :: Int) ->
-                 joinrec {
-                   go [InlPrag=[2], Occ=T[2]] :: Int -> Int -> Int
-                   [LclId[JoinId(2)],
-                    Arity=2,
-                    Str=<SP(L)><SP(SL)>,
-                    Unf=Unf{Src=InlineStable, TopLvl=False, Value=True, ConLike=True,
-                            WorkFree=True, Expandable=True,
-                            Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False)
-                            Tmpl= \ (z [Occ=Once1!, Dmd=SP(L)] :: Int)
-                                    (ds [Occ=Once1!, Dmd=SP(SL)] :: Int) ->
-                                    case z of { GHC.Types.I# ww [Occ=Once1] ->
-                                    case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] ->
-                                    jump $wgo ww ww
-                                    }
-                                    }}]
-                   go (z [Occ=Once1!, Dmd=SP(L)] :: Int)
-                      (ds [Occ=Once1!, Dmd=SP(SL)] :: Int)
-                     = case z of { GHC.Types.I# ww [Occ=Once1] ->
-                       case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] ->
-                       jump $wgo ww ww
-                       }
-                       };
-                   $wgo [InlPrag=[2], Occ=LoopBreakerT[2]]
-                     :: GHC.Prim.Int# -> GHC.Prim.Int# -> Int
-                   [LclId[JoinId(2)],
-                    Arity=2,
-                    Str=<L><SL>,
-                    Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
-                            WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 51] 69 10}]
-                   $wgo (ww [Occ=Once2] :: GHC.Prim.Int#)
-                        (ww [Occ=Once1!, Dmd=SL] :: GHC.Prim.Int#)
-                     = case ww of ds {
-                         __DEFAULT ->
-                           jump go
-                             (GHC.Types.I# (GHC.Prim.+# ww ds))
-                             (GHC.Types.I# (GHC.Prim.-# ds 1#));
-                         0# ->
-                           case x of { GHC.Types.I# y [Occ=Once1] ->
-                           GHC.Types.I# (GHC.Prim.*# ww y)
-                           }
-                       }; } in
-                 jump go lvl x}]
-small
-  = \ (x [Dmd=SP(SL)] :: Int) ->
+ Str=<SL>,
+ Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 35 0}]
+$wsmall
+  = \ (ww [Dmd=SL] :: GHC.Prim.Int#) ->
       join {
-        exit :: GHC.Prim.Int# -> Int
-        [LclId[JoinId(1)]]
-        exit (ww :: GHC.Prim.Int#)
-          = case x of { GHC.Types.I# y ->
-            GHC.Types.I# (GHC.Prim.*# ww y)
-            } } in
+        exit :: GHC.Prim.Int# -> GHC.Prim.Int#
+        [LclId[JoinId(1)(Nothing)]]
+        exit (ww :: GHC.Prim.Int#) = GHC.Prim.*# ww ww } in
       joinrec {
         $wgo [InlPrag=[2], Occ=LoopBreaker]
-          :: GHC.Prim.Int# -> GHC.Prim.Int# -> Int
-        [LclId[JoinId(2)],
+          :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#
+        [LclId[JoinId(2)(Just [])],
          Arity=2,
          Str=<L><SL>,
          Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
-                 WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 38] 49 10}]
+                 WorkFree=True, Expandable=True,
+                 Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=True)}]
         $wgo (ww :: GHC.Prim.Int#) (ww [Dmd=SL] :: GHC.Prim.Int#)
           = case ww of ds {
               __DEFAULT -> jump $wgo (GHC.Prim.+# ww ds) (GHC.Prim.-# ds 1#);
               0# -> jump exit ww
             }; } in
-      case x of { GHC.Types.I# ww [Dmd=SL] -> jump $wgo 0# ww }
+      jump $wgo 0# ww
+
+-- RHS size: {terms: 10, types: 4, coercions: 0, joins: 0/0}
+small [InlPrag=[2]] :: Int -> Int
+[LclIdX,
+ Arity=1,
+ Str=<S!P(SL)>,
+ Cpr=1,
+ Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True,
+         WorkFree=True, Expandable=True,
+         Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
+         Tmpl= \ (x [Occ=Once1!, Dmd=S!P(SL)] :: Int) ->
+                 case x of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] ->
+                 case $wsmall ww of ww [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww }
+                 }}]
+small
+  = \ (x [Dmd=S!P(SL)] :: Int) ->
+      case x of { GHC.Types.I# ww [Dmd=SL] ->
+      case $wsmall ww of ww { __DEFAULT -> GHC.Types.I# ww }
+      }
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
 $trModule :: GHC.Prim.Addr#
@@ -97,7 +62,7 @@ $trModule = "main"#
 $trModule :: GHC.Types.TrName
 [LclId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 $trModule = GHC.Types.TrNameS $trModule
 
 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
@@ -111,14 +76,14 @@ $trModule = "T20510"#
 $trModule :: GHC.Types.TrName
 [LclId,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}]
 $trModule = GHC.Types.TrNameS $trModule
 
 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
 T20510.$trModule :: GHC.Types.Module
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}]
 T20510.$trModule = GHC.Types.Module $trModule $trModule
 
 


=====================================
testsuite/tests/stranal/should_compile/T21128.stderr
=====================================
@@ -1,7 +1,7 @@
 
 ==================== Tidy Core ====================
 Result size of Tidy Core
-  = {terms: 125, types: 68, coercions: 4, joins: 0/0}
+  = {terms: 124, types: 69, coercions: 4, joins: 1/1}
 
 lvl = "error"#
 
@@ -48,12 +48,13 @@ index
   = \ l u i ->
       case l of { I# x ->
       case i of { I# y ->
+      join { $j = case u of { I# ww -> $wlvl y ww x } } in
       case <=# x y of {
-        __DEFAULT -> case u of { I# ww -> $wlvl y ww x };
+        __DEFAULT -> jump $j;
         1# ->
           case u of { I# y1 ->
           case <# y y1 of {
-            __DEFAULT -> $wlvl y y1 x;
+            __DEFAULT -> jump $j;
             1# -> I# (-# y x)
           }
           }
@@ -66,7 +67,7 @@ index
 
 ==================== Tidy Core ====================
 Result size of Tidy Core
-  = {terms: 108, types: 46, coercions: 0, joins: 3/3}
+  = {terms: 107, types: 47, coercions: 0, joins: 4/5}
 
 $trModule4 = "main"#
 
@@ -82,25 +83,27 @@ i = I# 1#
 
 l = I# 0#
 
-lvl = \ x ww -> indexError $fShowInt x (I# ww) i
+lvl = \ x y -> indexError $fShowInt x y i
 
-lvl1 = \ ww -> indexError $fShowInt l (I# ww) l
+lvl1 = \ y -> indexError $fShowInt l y l
 
 $wtheresCrud
   = \ ww ww1 ->
+      let { y = I# ww1 } in
       join {
         exit
           = case <# 0# ww1 of {
-              __DEFAULT -> case lvl1 ww1 of wild { };
+              __DEFAULT -> case lvl1 y of wild { };
               1# -> 0#
             } } in
       join {
         exit1
-          = case <=# ww 1# of {
-              __DEFAULT -> case lvl (I# ww) ww1 of wild { };
+          = join { $j = case lvl (I# ww) y of wild { } } in
+            case <=# ww 1# of {
+              __DEFAULT -> jump $j;
               1# ->
                 case <# 1# ww1 of {
-                  __DEFAULT -> case lvl (I# ww) ww1 of wild { };
+                  __DEFAULT -> jump $j;
                   1# -> -# 1# ww
                 }
             } } in


=====================================
testsuite/tests/typecheck/should_compile/T13032.stderr
=====================================
@@ -16,7 +16,7 @@ f = \ (@a) (@b) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] ->
 T13032.$trModule :: GHC.Types.Module
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
-         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}]
+         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}]
 T13032.$trModule
   = GHC.Types.Module
       (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T13032"#)


=====================================
utils/check-exact/ExactPrint.hs
=====================================
@@ -15,6 +15,7 @@
 {-# LANGUAGE TypeOperators        #-}
 {-# LANGUAGE BlockArguments       #-}
 {-# LANGUAGE UndecidableInstances  #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance
+{-# OPTIONS_GHC -Wno-unused-matches -Wno-incomplete-uni-patterns #-}
 
 module ExactPrint
   (



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e8398e79655fa8e82da7244796a2ed9ddfdb0e8...dc021331f99ee4b3e699350312f0aef27f4c6a47

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e8398e79655fa8e82da7244796a2ed9ddfdb0e8...dc021331f99ee4b3e699350312f0aef27f4c6a47
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221213/034c80aa/attachment-0001.html>


More information about the ghc-commits mailing list