diff options
18 files changed, 150 insertions, 192 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 diff --git a/testsuite/tests/deSugar/should_compile/T13208.stdout b/testsuite/tests/deSugar/should_compile/T13208.stdout index b7ba07cdf4..b136dd6c7a 100644 --- a/testsuite/tests/deSugar/should_compile/T13208.stdout +++ b/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}] diff --git a/testsuite/tests/deSugar/should_compile/T16615.stderr b/testsuite/tests/deSugar/should_compile/T16615.stderr index 0a758bb046..09a60ae8c1 100644 --- a/testsuite/tests/deSugar/should_compile/T16615.stderr +++ b/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); diff --git a/testsuite/tests/numeric/should_compile/T14170.stdout b/testsuite/tests/numeric/should_compile/T14170.stdout index 286d60bc0a..a54a8c16e7 100644 --- a/testsuite/tests/numeric/should_compile/T14170.stdout +++ b/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# diff --git a/testsuite/tests/numeric/should_compile/T14465.stdout b/testsuite/tests/numeric/should_compile/T14465.stdout index 7ce467bc60..99037647f1 100644 --- a/testsuite/tests/numeric/should_compile/T14465.stdout +++ b/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} diff --git a/testsuite/tests/numeric/should_compile/T7116.stdout b/testsuite/tests/numeric/should_compile/T7116.stdout index 407a057855..61c2a1a51a 100644 --- a/testsuite/tests/numeric/should_compile/T7116.stdout +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T13143.stderr b/testsuite/tests/simplCore/should_compile/T13143.stderr index 1d4b3dd9fa..6cde9f08d6 100644 --- a/testsuite/tests/simplCore/should_compile/T13143.stderr +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T18013.stderr b/testsuite/tests/simplCore/should_compile/T18013.stderr index 76cfd792cc..6644f72d8d 100644 --- a/testsuite/tests/simplCore/should_compile/T18013.stderr +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T3717.stderr b/testsuite/tests/simplCore/should_compile/T3717.stderr index 5da8a9f302..9462c548c1 100644 --- a/testsuite/tests/simplCore/should_compile/T3717.stderr +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T3772.stdout b/testsuite/tests/simplCore/should_compile/T3772.stdout index 6faaab181a..2bb6e4d4b3 100644 --- a/testsuite/tests/simplCore/should_compile/T3772.stdout +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T4908.stderr b/testsuite/tests/simplCore/should_compile/T4908.stderr index a306a5a5e7..fa8c0826c1 100644 --- a/testsuite/tests/simplCore/should_compile/T4908.stderr +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T4930.stderr b/testsuite/tests/simplCore/should_compile/T4930.stderr index bc6bacdb40..cc48a554ac 100644 --- a/testsuite/tests/simplCore/should_compile/T4930.stderr +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/T7360.stderr b/testsuite/tests/simplCore/should_compile/T7360.stderr index f97a638736..3cbdeb9431 100644 --- a/testsuite/tests/simplCore/should_compile/T7360.stderr +++ b/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 diff --git a/testsuite/tests/simplCore/should_compile/spec-inline.stderr b/testsuite/tests/simplCore/should_compile/spec-inline.stderr index 97bbeabcc1..ddb57526a2 100644 --- a/testsuite/tests/simplCore/should_compile/spec-inline.stderr +++ b/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} diff --git a/testsuite/tests/stranal/should_compile/T20510.stderr b/testsuite/tests/stranal/should_compile/T20510.stderr index b2cbed4594..8a5bae328b 100644 --- a/testsuite/tests/stranal/should_compile/T20510.stderr +++ b/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 diff --git a/testsuite/tests/stranal/should_compile/T21128.stderr b/testsuite/tests/stranal/should_compile/T21128.stderr index 955717ef35..bfbe31877d 100644 --- a/testsuite/tests/stranal/should_compile/T21128.stderr +++ b/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 diff --git a/testsuite/tests/typecheck/should_compile/T13032.stderr b/testsuite/tests/typecheck/should_compile/T13032.stderr index 3855f728c5..ac31489efa 100644 --- a/testsuite/tests/typecheck/should_compile/T13032.stderr +++ b/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"#) diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs index d2005c6733..f802cabe43 100644 --- a/utils/check-exact/ExactPrint.hs +++ b/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 ( |