diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2021-04-28 14:55:26 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-24 01:26:46 -0400 |
commit | 3bab222c585343f8febe2a627d280b7be9401e92 (patch) | |
tree | bb95653710d6ac277a88f8011c4e491a73531a64 /testsuite | |
parent | 8300ca2e3bcc3e74f7524116f85688da6167bb2f (diff) | |
download | haskell-3bab222c585343f8febe2a627d280b7be9401e92.tar.gz |
DmdAnal: Implement Boxity Analysis (#19871)
This patch fixes some abundant reboxing of `DynFlags` in
`GHC.HsToCore.Match.Literal.warnAboutOverflowedLit` (which was the topic
of #19407) by introducing a Boxity analysis to GHC, done as part of demand
analysis. This allows to accurately capture ad-hoc unboxing decisions previously
made in worker/wrapper in demand analysis now, where the boxity info can
propagate through demand signatures.
See the new `Note [Boxity analysis]`. The actual fix for #19407 is described in
`Note [No lazy, Unboxed demand in demand signature]`, but
`Note [Finalising boxity for demand signature]` is probably a better entry-point.
To support the fix for #19407, I had to change (what was)
`Note [Add demands for strict constructors]` a bit
(now `Note [Unboxing evaluated arguments]`). In particular, we now take care of
it in `finaliseBoxity` (which is only called from demand analaysis) instead of
`wantToUnboxArg`.
I also had to resurrect `Note [Product demands for function body]` and rename
it to `Note [Unboxed demand on function bodies returning small products]` to
avoid huge regressions in `join004` and `join007`, thereby fixing #4267 again.
See the updated Note for details.
A nice side-effect is that the worker/wrapper transformation no longer needs to
look at strictness info and other bits such as `InsideInlineableFun` flags
(needed for `Note [Do not unbox class dictionaries]`) at all. It simply collects
boxity info from argument demands and interprets them with a severely simplified
`wantToUnboxArg`. All the smartness is in `finaliseBoxity`, which could be moved
to DmdAnal completely, if it wasn't for the call to `dubiousDataConInstArgTys`
which would be awkward to export.
I spent some time figuring out the reason for why `T16197` failed prior to my
amendments to `Note [Unboxing evaluated arguments]`. After having it figured
out, I minimised it a bit and added `T16197b`, which simply compares computed
strictness signatures and thus should be far simpler to eyeball.
The 12% ghc/alloc regression in T11545 is because of the additional `Boxity`
field in `Poly` and `Prod` that results in more allocation during `lubSubDmd`
and `plusSubDmd`. I made sure in the ticky profiles that the number of calls
to those functions stayed the same. We can bear such an increase here, as we
recently improved it by -68% (in b760c1f).
T18698* regress slightly because there is more unboxing of dictionaries
happening and that causes Lint (mostly) to allocate more.
Fixes #19871, #19407, #4267, #16859, #18907 and #13331.
Metric Increase:
T11545
T18698a
T18698b
Metric Decrease:
T12425
T16577
T18223
T18282
T4267
T9961
Diffstat (limited to 'testsuite')
51 files changed, 892 insertions, 438 deletions
diff --git a/testsuite/tests/arityanal/should_compile/Arity04.stderr b/testsuite/tests/arityanal/should_compile/Arity04.stderr index d2f6457a03..2adcacff39 100644 --- a/testsuite/tests/arityanal/should_compile/Arity04.stderr +++ b/testsuite/tests/arityanal/should_compile/Arity04.stderr @@ -6,8 +6,8 @@ Result size of Tidy Core = {terms: 39, types: 24, coercions: 0, joins: 0/0} f4g :: Int -> Int [GblId, Arity=1, - Str=<1P(L)>, - Cpr=m1, + Str=<1!P(L)>, + 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= \ (y [Occ=Once1!] :: Int) -> case y of { GHC.Types.I# x [Occ=Once1] -> GHC.Types.I# (GHC.Prim.+# x 1#) }}] f4g = \ (y :: Int) -> case y of { GHC.Types.I# x -> GHC.Types.I# (GHC.Prim.+# x 1#) } @@ -22,10 +22,10 @@ Rec { F4.$wf4h [InlPrag=[2], Occ=LoopBreaker] :: (Int -> Int) -> GHC.Prim.Int# -> Int [GblId, Arity=2, Str=<1C1(L)><1L>, Unf=OtherCon []] F4.$wf4h - = \ (w :: Int -> Int) (ww :: GHC.Prim.Int#) -> + = \ (f :: Int -> Int) (ww :: GHC.Prim.Int#) -> case ww of wild { - __DEFAULT -> F4.$wf4h w (GHC.Prim.-# wild 1#); - 0# -> w lvl + __DEFAULT -> F4.$wf4h f (GHC.Prim.-# wild 1#); + 0# -> f lvl } end Rec } @@ -33,10 +33,10 @@ end Rec } f4h [InlPrag=[2]] :: (Int -> Int) -> Int -> Int [GblId, Arity=2, - Str=<1C1(L)><1P(1L)>, + Str=<1C1(L)><1!P(1L)>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once1] :: Int -> Int) (w1 [Occ=Once1!] :: Int) -> case w1 of { GHC.Types.I# ww1 [Occ=Once1] -> F4.$wf4h w ww1 }}] -f4h = \ (w :: Int -> Int) (w1 :: Int) -> case w1 of { GHC.Types.I# ww1 -> F4.$wf4h w ww1 } + Tmpl= \ (f [Occ=Once1] :: Int -> Int) (x [Occ=Once1!] :: Int) -> case x of { GHC.Types.I# ww [Occ=Once1] -> F4.$wf4h f ww }}] +f4h = \ (f :: Int -> Int) (x :: Int) -> case x of { GHC.Types.I# ww -> F4.$wf4h f ww } -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} f4 :: Int diff --git a/testsuite/tests/arityanal/should_compile/Arity11.stderr b/testsuite/tests/arityanal/should_compile/Arity11.stderr index da35b40ab8..48b37a13db 100644 --- a/testsuite/tests/arityanal/should_compile/Arity11.stderr +++ b/testsuite/tests/arityanal/should_compile/Arity11.stderr @@ -73,7 +73,7 @@ F11.$wfib fib [InlPrag=[2]] :: forall {t} {a}. (Eq t, Num t, Num a) => t -> a [GblId, Arity=4, - Str=<1P(SCS(C1(L)),A)><LP(A,LCL(C1(L)),A,A,A,A,L)><LP(LCL(C1(L)),A,A,A,A,A,L)><L>, + Str=<1!P(SCS(C1(L)),A)><LP(A,LCL(C1(L)),A,A,A,A,L)><LP(LCL(C1(L)),A,A,A,A,A,L)><L>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=4,unsat_ok=True,boring_ok=False) Tmpl= \ (@t) (@a) (w [Occ=Once1!] :: Eq t) (w1 [Occ=Once1] :: Num t) (w2 [Occ=Once1] :: Num a) (w3 [Occ=Once1] :: t) -> case w of { GHC.Classes.C:Eq ww [Occ=Once1] _ [Occ=Dead] -> F11.$wfib @t @a ww w1 w2 w3 }}] fib = \ (@t) (@a) (w :: Eq t) (w1 :: Num t) (w2 :: Num a) (w3 :: t) -> case w of { GHC.Classes.C:Eq ww ww1 -> F11.$wfib @t @a ww w1 w2 w3 } diff --git a/testsuite/tests/arityanal/should_compile/Arity14.stderr b/testsuite/tests/arityanal/should_compile/Arity14.stderr index ee54686a29..efd90363c6 100644 --- a/testsuite/tests/arityanal/should_compile/Arity14.stderr +++ b/testsuite/tests/arityanal/should_compile/Arity14.stderr @@ -41,7 +41,7 @@ F14.$wf14 f14 [InlPrag=[2]] :: forall {t}. (Ord t, Num t) => t -> t -> t -> t [GblId, Arity=4, - Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(LCL(C1(L)),A,A,A,A,A,L)><L><L>, + Str=<1!P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(LCL(C1(L)),A,A,A,A,A,L)><L><L>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=4,unsat_ok=True,boring_ok=False) Tmpl= \ (@t) (w [Occ=Once1!] :: Ord t) (w1 [Occ=Once1] :: Num t) (w2 [Occ=Once1] :: t) (w3 [Occ=Once1] :: t) -> case w of { GHC.Classes.C:Ord _ [Occ=Dead] _ [Occ=Dead] ww2 [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> F14.$wf14 @t ww2 w1 w2 w3 }}] f14 = \ (@t) (w :: Ord t) (w1 :: Num t) (w2 :: t) (w3 :: t) -> case w of { GHC.Classes.C:Ord ww ww1 ww2 ww3 ww4 ww5 ww6 ww7 -> F14.$wf14 @t ww2 w1 w2 w3 } diff --git a/testsuite/tests/arityanal/should_compile/T18793.stderr b/testsuite/tests/arityanal/should_compile/T18793.stderr index 6ea36558be..39ce9b9a54 100644 --- a/testsuite/tests/arityanal/should_compile/T18793.stderr +++ b/testsuite/tests/arityanal/should_compile/T18793.stderr @@ -1,28 +1,19 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 66, types: 43, coercions: 0, joins: 0/0} +Result size of Tidy Core = {terms: 64, types: 40, coercions: 0, joins: 0/0} --- RHS size: {terms: 15, types: 5, coercions: 0, joins: 0/0} -T18793.$wstuff [InlPrag=NOINLINE] :: GHC.Prim.Int# -> [Int] -[GblId, Arity=1, Str=<L>, Unf=OtherCon []] -T18793.$wstuff = \ (ww :: GHC.Prim.Int#) -> GHC.Types.: @Int (GHC.Types.I# ww) (GHC.Types.: @Int (GHC.Types.I# (GHC.Prim.+# ww 1#)) (GHC.Types.: @Int (GHC.Types.I# (GHC.Prim.+# ww 2#)) (GHC.Types.[] @Int))) - --- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0} -stuff [InlPrag=[final]] :: Int -> [Int] -[GblId, - Arity=1, - Str=<1P(L)>, - 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= \ (w [Occ=Once1!] :: Int) -> case w of { GHC.Types.I# ww [Occ=Once1] -> T18793.$wstuff ww }}] -stuff = \ (w :: Int) -> case w of { GHC.Types.I# ww -> T18793.$wstuff ww } +-- RHS size: {terms: 17, types: 7, coercions: 0, joins: 0/0} +stuff [InlPrag=NOINLINE] :: Int -> [Int] +[GblId, Arity=1, Str=<1L>, Unf=OtherCon []] +stuff = \ (i :: Int) -> case i of i1 { GHC.Types.I# ipv -> GHC.Types.: @Int i1 (GHC.Types.: @Int (GHC.Types.I# (GHC.Prim.+# ipv 1#)) (GHC.Types.: @Int (GHC.Types.I# (GHC.Prim.+# ipv 2#)) (GHC.Types.[] @Int))) } Rec { -- RHS size: {terms: 23, types: 11, coercions: 0, joins: 0/0} T18793.$wgo1 [InlPrag=[2], Occ=LoopBreaker] :: [Int] -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId, Arity=2, Str=<1L><L>, Unf=OtherCon []] T18793.$wgo1 - = \ (w :: [Int]) (ww :: GHC.Prim.Int#) -> - case w of { + = \ (ds :: [Int]) (ww :: GHC.Prim.Int#) -> + case ds of { [] -> ww; : y ys -> case y of { GHC.Types.I# x -> @@ -38,20 +29,25 @@ end Rec } T18793.f_go1 [InlPrag=[2]] :: [Int] -> Int -> Int [GblId, Arity=2, - Str=<1L><1P(L)>, + Str=<1L><1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once1] :: [Int]) (w1 [Occ=Once1!] :: Int) -> case w1 of { GHC.Types.I# ww [Occ=Once1] -> case T18793.$wgo1 w ww of ww1 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww1 } }}] -T18793.f_go1 = \ (w :: [Int]) (w1 :: Int) -> case w1 of { GHC.Types.I# ww -> case T18793.$wgo1 w ww of ww1 { __DEFAULT -> GHC.Types.I# ww1 } } + Tmpl= \ (ds [Occ=Once1] :: [Int]) (eta [Occ=Once1!] :: Int) -> case eta of { GHC.Types.I# ww [Occ=Once1] -> case T18793.$wgo1 ds ww of ww1 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww1 } }}] +T18793.f_go1 = \ (ds :: [Int]) (eta :: Int) -> case eta of { GHC.Types.I# ww -> case T18793.$wgo1 ds ww of ww1 { __DEFAULT -> GHC.Types.I# ww1 } } + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18793.f2 :: Int +[GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T18793.f2 = GHC.Types.I# 1# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18793.f1 :: [Int] [GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False, WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}] -T18793.f1 = T18793.$wstuff 1# +T18793.f1 = stuff T18793.f2 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} f :: Int -> Int -[GblId, Arity=1, Str=<1P(L)>, Cpr=1, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 60}] +[GblId, Arity=1, Str=<1!L>, Cpr=1, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 60}] f = T18793.f_go1 T18793.f1 diff --git a/testsuite/tests/cpranal/should_compile/T18109.hs b/testsuite/tests/cpranal/should_compile/T18109.hs index 5c52a187c9..fb79c749a3 100644 --- a/testsuite/tests/cpranal/should_compile/T18109.hs +++ b/testsuite/tests/cpranal/should_compile/T18109.hs @@ -14,8 +14,8 @@ f n = F (+n) data T = T (Int, Int) -g :: T -> T -g t@(T p) = p `seq` t +g :: (Int, Int) -> T +g p = p `seq` T p {-# NOINLINE g #-} data U = U ![Int] diff --git a/testsuite/tests/cpranal/should_compile/T18109.stderr b/testsuite/tests/cpranal/should_compile/T18109.stderr index ad92bdda17..f547ac62d7 100644 --- a/testsuite/tests/cpranal/should_compile/T18109.stderr +++ b/testsuite/tests/cpranal/should_compile/T18109.stderr @@ -1,51 +1,51 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 78, types: 81, coercions: 0, joins: 0/1} +Result size of Tidy Core = {terms: 75, types: 81, coercions: 0, joins: 0/1} -- RHS size: {terms: 6, types: 4, coercions: 0, joins: 0/0} T18109.$WU :: [Int] %1 -> U -T18109.$WU = \ (dt_aDr :: [Int]) -> case dt_aDr of dt_X0 { __DEFAULT -> T18109.U dt_X0 } +T18109.$WU = \ (conrep_aDI :: [Int]) -> case conrep_aDI of conrep_X0 { __DEFAULT -> T18109.U conrep_X0 } -- RHS size: {terms: 6, types: 12, coercions: 0, joins: 0/0} T18109.$wg :: (Int, Int) -> (# (Int, Int) #) -T18109.$wg = \ (ww_sKr :: (Int, Int)) -> case ww_sKr of p_X2 { (ipv_sIU, ipv1_sIV) -> (# p_X2 #) } +T18109.$wg = \ (p_sL1 :: (Int, Int)) -> case p_sL1 of p1_X0 { (ipv_sJr, ipv1_sJs) -> (# p1_X0 #) } --- RHS size: {terms: 10, types: 13, coercions: 0, joins: 0/0} -g :: T -> T -g = \ (w_sKp :: T) -> case w_sKp of { T ww_sKr -> case T18109.$wg ww_sKr of { (# ww1_sKJ #) -> T18109.T ww1_sKJ } } +-- RHS size: {terms: 7, types: 11, coercions: 0, joins: 0/0} +g :: (Int, Int) -> T +g = \ (p_sL1 :: (Int, Int)) -> case T18109.$wg p_sL1 of { (# ww_sLl #) -> T18109.T ww_sLl } -- RHS size: {terms: 6, types: 5, coercions: 0, joins: 0/0} T18109.$wf :: Int -> (# Int -> Int #) -T18109.$wf = \ (w_sKw :: Int) -> (# \ (v_B2 :: Int) -> GHC.Num.$fNumInt_$c+ v_B2 w_sKw #) +T18109.$wf = \ (n_sL6 :: Int) -> (# \ (v_B2 :: Int) -> GHC.Num.$fNumInt_$c+ v_B2 n_sL6 #) -- RHS size: {terms: 7, types: 7, coercions: 0, joins: 0/0} f :: Int -> F -f = \ (w_sKw :: Int) -> case T18109.$wf w_sKw of { (# ww_sKL #) -> T18109.F ww_sKL } +f = \ (n_sL6 :: Int) -> case T18109.$wf n_sL6 of { (# ww_sLn #) -> T18109.F ww_sLn } -- RHS size: {terms: 26, types: 10, coercions: 0, joins: 0/1} T18109.$wh :: GHC.Prim.Int# -> [Int] T18109.$wh - = \ (ww_sKE :: GHC.Prim.Int#) -> - case GHC.Prim.># 0# ww_sKE of { + = \ (ww_sLg :: GHC.Prim.Int#) -> + case GHC.Prim.># 0# ww_sLg of { __DEFAULT -> letrec { - go3_aKm :: GHC.Prim.Int# -> [Int] - go3_aKm - = \ (x_aKn :: GHC.Prim.Int#) -> + go3_aKV :: GHC.Prim.Int# -> [Int] + go3_aKV + = \ (x_aKW :: GHC.Prim.Int#) -> GHC.Types.: @Int - (GHC.Types.I# x_aKn) - (case GHC.Prim.==# x_aKn ww_sKE of { - __DEFAULT -> go3_aKm (GHC.Prim.+# x_aKn 1#); + (GHC.Types.I# x_aKW) + (case GHC.Prim.==# x_aKW ww_sLg of { + __DEFAULT -> go3_aKV (GHC.Prim.+# x_aKW 1#); 1# -> GHC.Types.[] @Int }); } in - go3_aKm 0#; + go3_aKV 0#; 1# -> GHC.Types.[] @Int } -- RHS size: {terms: 10, types: 5, coercions: 0, joins: 0/0} h :: Int -> U -h = \ (w_sKC :: Int) -> case w_sKC of { GHC.Types.I# ww_sKE -> case T18109.$wh ww_sKE of ww1_sKN { __DEFAULT -> T18109.U ww1_sKN } } +h = \ (n_sLe :: Int) -> case n_sLe of { GHC.Types.I# ww_sLg -> case T18109.$wh ww_sLg of ww1_sLp { __DEFAULT -> T18109.U ww1_sLp } } diff --git a/testsuite/tests/cpranal/sigs/T19398.hs b/testsuite/tests/cpranal/sigs/T19398.hs index e0347fd502..d4d8f295d8 100644 --- a/testsuite/tests/cpranal/sigs/T19398.hs +++ b/testsuite/tests/cpranal/sigs/T19398.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# OPTIONS_GHC -fdmd-unbox-width=0 #-} -- otherwise we'll optimistically unbox the arg to c module T19398 where @@ -24,9 +25,3 @@ a n -- unsound. c :: (Int, Int) -> Int c (x,_) = x - --- | An interesting artifact is that the following function has the Nested CPR --- property, and we could in theory exploit that: -g :: (Int, Int) -> (Int, Int) -g p@(!x, !y) | x == y = error "blah" -g p = p diff --git a/testsuite/tests/cpranal/sigs/T19398.stderr b/testsuite/tests/cpranal/sigs/T19398.stderr index faa335d399..d734b84c4b 100644 --- a/testsuite/tests/cpranal/sigs/T19398.stderr +++ b/testsuite/tests/cpranal/sigs/T19398.stderr @@ -3,6 +3,5 @@ T19398.a: T19398.c: T19398.f: 1 -T19398.g: 1(1, 1) diff --git a/testsuite/tests/cpranal/sigs/T19822.stderr b/testsuite/tests/cpranal/sigs/T19822.stderr index 607e806e8c..8e4636d322 100644 --- a/testsuite/tests/cpranal/sigs/T19822.stderr +++ b/testsuite/tests/cpranal/sigs/T19822.stderr @@ -1,5 +1,5 @@ ==================== Cpr signatures ==================== -T19822.singleton: 1(, 1) +T19822.singleton: 1 diff --git a/testsuite/tests/numeric/should_compile/T7116.stdout b/testsuite/tests/numeric/should_compile/T7116.stdout index ad3878e35a..3c30cf2e8b 100644 --- a/testsuite/tests/numeric/should_compile/T7116.stdout +++ b/testsuite/tests/numeric/should_compile/T7116.stdout @@ -43,7 +43,7 @@ T7116.$trModule dr :: Double -> Double [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -60,7 +60,7 @@ dr dl :: Double -> Double [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -71,7 +71,7 @@ dl = dr fr :: Float -> Float [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -90,7 +90,7 @@ fr fl :: Float -> Float [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/simplCore/should_compile/T13143.stderr b/testsuite/tests/simplCore/should_compile/T13143.stderr index c4c2db7462..6123f91292 100644 --- a/testsuite/tests/simplCore/should_compile/T13143.stderr +++ b/testsuite/tests/simplCore/should_compile/T13143.stderr @@ -89,7 +89,7 @@ end Rec } g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int [GblId, Arity=3, - Str=<1L><1L><1P(L)>, + Str=<1L><1L><1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/simplCore/should_compile/T13543.stderr b/testsuite/tests/simplCore/should_compile/T13543.stderr index 90bda9792f..485f6fea41 100644 --- a/testsuite/tests/simplCore/should_compile/T13543.stderr +++ b/testsuite/tests/simplCore/should_compile/T13543.stderr @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== Foo.$trModule: -Foo.f: <1P(1L)><1P(L)><1P(L)> -Foo.g: <1P(1P(L),1P(L))> +Foo.f: <1!P(1L)><1!L><1!L> +Foo.g: <1!P(1!L,1!L)> @@ -15,7 +15,7 @@ Foo.g: 1 ==================== Strictness signatures ==================== Foo.$trModule: -Foo.f: <1P(1L)><1P(L)><1P(L)> -Foo.g: <1P(1P(L),1P(L))> +Foo.f: <1!P(1L)><1!L><1!L> +Foo.g: <1!P(1!L,1!L)> diff --git a/testsuite/tests/simplCore/should_compile/T18013.stderr b/testsuite/tests/simplCore/should_compile/T18013.stderr index 5fe7eec578..134078e7e8 100644 --- a/testsuite/tests/simplCore/should_compile/T18013.stderr +++ b/testsuite/tests/simplCore/should_compile/T18013.stderr @@ -138,7 +138,7 @@ mapMaybeRule [InlPrag=[2]] :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) [GblId, Arity=1, - Str=<1P(L,LCL(C1(C1(P(L,1P(L,L))))))>, + Str=<1!P(L,LCL(C1(C1(P(L,1L)))))>, 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) diff --git a/testsuite/tests/simplCore/should_compile/T3717.stderr b/testsuite/tests/simplCore/should_compile/T3717.stderr index bd6417b729..f131214132 100644 --- a/testsuite/tests/simplCore/should_compile/T3717.stderr +++ b/testsuite/tests/simplCore/should_compile/T3717.stderr @@ -56,7 +56,7 @@ end Rec } foo [InlPrag=[2]] :: Int -> Int [GblId, Arity=1, - Str=<1P(1L)>, + Str=<1!P(1L)>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/simplCore/should_compile/T3772.stdout b/testsuite/tests/simplCore/should_compile/T3772.stdout index 96830336bc..c63beeca95 100644 --- a/testsuite/tests/simplCore/should_compile/T3772.stdout +++ b/testsuite/tests/simplCore/should_compile/T3772.stdout @@ -65,7 +65,7 @@ T3772.$wfoo foo [InlPrag=[final]] :: Int -> () [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/simplCore/should_compile/T4201.stdout b/testsuite/tests/simplCore/should_compile/T4201.stdout index 383d652757..1e338e43fd 100644 --- a/testsuite/tests/simplCore/should_compile/T4201.stdout +++ b/testsuite/tests/simplCore/should_compile/T4201.stdout @@ -1,4 +1,4 @@ lift :: Foo -> T [HasNoCafRefs, LambdaFormInfo: LFReEntrant 1, Arity: 1, - Strictness: <1L>, + Strictness: <1!A>, CPR: 1, Unfolding: (bof `cast` (Sym (N:Foo[0]) %<'Many>_N ->_R <T>_R))] diff --git a/testsuite/tests/simplCore/should_compile/T4908.stderr b/testsuite/tests/simplCore/should_compile/T4908.stderr index c74c5ce2ff..9cfd79d1e0 100644 --- a/testsuite/tests/simplCore/should_compile/T4908.stderr +++ b/testsuite/tests/simplCore/should_compile/T4908.stderr @@ -59,7 +59,7 @@ end Rec } f [InlPrag=[2]] :: Int -> (Int, Int) -> Bool [GblId, Arity=2, - Str=<1P(1L)><MP(A,MP(ML))>, + Str=<1!P(1L)><MP(A,MP(ML))>, Cpr=2, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/simplCore/should_compile/T4930.stderr b/testsuite/tests/simplCore/should_compile/T4930.stderr index 9da0009f84..b8d14764ce 100644 --- a/testsuite/tests/simplCore/should_compile/T4930.stderr +++ b/testsuite/tests/simplCore/should_compile/T4930.stderr @@ -56,7 +56,7 @@ end Rec } foo [InlPrag=[2]] :: Int -> Int [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/simplCore/should_compile/spec-inline.stderr b/testsuite/tests/simplCore/should_compile/spec-inline.stderr index 2ba178e6bf..40746ff717 100644 --- a/testsuite/tests/simplCore/should_compile/spec-inline.stderr +++ b/testsuite/tests/simplCore/should_compile/spec-inline.stderr @@ -143,7 +143,7 @@ Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 foo :: Int -> Int [GblId, Arity=1, - Str=<1P(L)>, + Str=<1!L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, diff --git a/testsuite/tests/stranal/T10482a.hs b/testsuite/tests/stranal/T10482a.hs index 76f134f3e6..f481bd1712 100644 --- a/testsuite/tests/stranal/T10482a.hs +++ b/testsuite/tests/stranal/T10482a.hs @@ -22,7 +22,7 @@ f1 x = case h x x of ------- f2 ----------- --- We used to unbox x here and rebox it in the wrapper. After #17932, we don't. +-- We used to unbox x here and rebox it in the wrapper. -- After #17932, we don't. -- Historical comment: -- x is a strict field of MkT2, so we'll pass it unboxed diff --git a/testsuite/tests/stranal/should_compile/T10482.hs b/testsuite/tests/stranal/should_compile/T10482.hs index ef7c29c4be..d9bbe8bd8b 100644 --- a/testsuite/tests/stranal/should_compile/T10482.hs +++ b/testsuite/tests/stranal/should_compile/T10482.hs @@ -11,4 +11,4 @@ foo !f k = if k == 0 then 0 else if even k then foo f (k-1) else case f of - FooPair (FooPair (Foo n) _) _ -> n + FooPair (FooPair (Foo n) _) _ -> n+1 -- +1 so that we'll unbox diff --git a/testsuite/tests/stranal/should_compile/T10482.stderr b/testsuite/tests/stranal/should_compile/T10482.stderr index 387fca39de..ae512dcbe1 100644 --- a/testsuite/tests/stranal/should_compile/T10482.stderr +++ b/testsuite/tests/stranal/should_compile/T10482.stderr @@ -1,27 +1,27 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 167, types: 116, coercions: 15, joins: 0/0} +Result size of Tidy Core = {terms: 171, types: 112, coercions: 15, joins: 0/0} --- RHS size: {terms: 13, types: 14, coercions: 4, joins: 0/0} +-- RHS size: {terms: 13, types: 12, coercions: 4, joins: 0/0} T10482.$WFooPair [InlPrag=INLINE[final] CONLIKE] :: forall a b. Foo a %1 -> Foo b %1 -> Foo (a, b) [GblId[DataConWrapper], Arity=2, Caf=NoCafRefs, - Str=<S,U><S,U>, - Cpr=m1, + Str=<SL><SL>, + Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (@a_atI) (@b_atJ) (dt_aSX [Occ=Once1] :: Foo a_atI) (dt_aSY [Occ=Once1] :: Foo b_atJ) -> - (case dt_aSX of dt_X0 [Occ=Once1] { __DEFAULT -> - case dt_aSY of dt_X1 [Occ=Once1] { __DEFAULT -> T10482.FooPair @a_atI @b_atJ dt_X0 dt_X1 } + Tmpl= \ (@a_au1) (@b_au2) (dt_aTh [Occ=Once1] :: Foo a_au1) (dt_aTi [Occ=Once1] :: Foo b_au2) -> + (case dt_aTh of dt_X0 [Occ=Once1] { __DEFAULT -> + case dt_aTi of dt_X1 [Occ=Once1] { __DEFAULT -> T10482.FooPair @a_au1 @b_au2 dt_X0 dt_X1 } }) - `cast` (Sym (T10482.D:R:Foo(,)0[0] <a_atI>_N <b_atJ>_N) :: T10482.R:Foo(,) a_atI b_atJ ~R# Foo (a_atI, b_atJ))}] + `cast` (Sym (T10482.D:R:Foo(,)0[0] <a_au1>_N <b_au2>_N) :: T10482.R:Foo(,) a_au1 b_au2 ~R# Foo (a_au1, b_au2))}] T10482.$WFooPair - = \ (@a_atI) (@b_atJ) (dt_aSX [Occ=Once1] :: Foo a_atI) (dt_aSY [Occ=Once1] :: Foo b_atJ) -> - (case dt_aSX of dt_X0 [Occ=Once1] { __DEFAULT -> - case dt_aSY of dt_X1 [Occ=Once1] { __DEFAULT -> T10482.FooPair @a_atI @b_atJ dt_X0 dt_X1 } + = \ (@a_au1) (@b_au2) (dt_aTh [Occ=Once1] :: Foo a_au1) (dt_aTi [Occ=Once1] :: Foo b_au2) -> + (case dt_aTh of dt_X0 [Occ=Once1] { __DEFAULT -> + case dt_aTi of dt_X1 [Occ=Once1] { __DEFAULT -> T10482.FooPair @a_au1 @b_au2 dt_X0 dt_X1 } }) - `cast` (Sym (T10482.D:R:Foo(,)0[0] <a_atI>_N <b_atJ>_N) :: T10482.R:Foo(,) a_atI b_atJ ~R# Foo (a_atI, b_atJ)) + `cast` (Sym (T10482.D:R:Foo(,)0[0] <a_au1>_N <b_au2>_N) :: T10482.R:Foo(,) a_au1 b_au2 ~R# Foo (a_au1, b_au2)) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T10482.$trModule4 :: GHC.Prim.Addr# @@ -49,34 +49,34 @@ T10482.$trModule :: GHC.Types.Module T10482.$trModule = GHC.Types.Module T10482.$trModule3 T10482.$trModule1 -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} -$krep_r12A :: GHC.Types.KindRep +$krep_r11Y :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep_r12A = GHC.Types.KindRepTyConApp GHC.Types.$tcInt (GHC.Types.[] @GHC.Types.KindRep) +$krep_r11Y = GHC.Types.KindRepTyConApp GHC.Types.$tcInt (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -$krep1_r12B :: GHC.Types.KindRep +$krep1_r11Z :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep1_r12B = GHC.Types.KindRepVar 1# +$krep1_r11Z = GHC.Types.KindRepVar 1# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -$krep2_r12C :: GHC.Types.KindRep +$krep2_r120 :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep2_r12C = GHC.Types.KindRepVar 0# +$krep2_r120 = GHC.Types.KindRepVar 0# -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} -$krep3_r12D :: [GHC.Types.KindRep] +$krep3_r121 :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep3_r12D = GHC.Types.: @GHC.Types.KindRep $krep1_r12B (GHC.Types.[] @GHC.Types.KindRep) +$krep3_r121 = GHC.Types.: @GHC.Types.KindRep $krep1_r11Z (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} -$krep4_r12E :: [GHC.Types.KindRep] +$krep4_r122 :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep4_r12E = GHC.Types.: @GHC.Types.KindRep $krep2_r12C $krep3_r12D +$krep4_r122 = GHC.Types.: @GHC.Types.KindRep $krep2_r120 $krep3_r121 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep5_r12F :: GHC.Types.KindRep +$krep5_r123 :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep5_r12F = GHC.Types.KindRepTyConApp GHC.Tuple.$tc(,) $krep4_r12E +$krep5_r123 = GHC.Types.KindRepTyConApp GHC.Tuple.$tc(,) $krep4_r122 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T10482.$tcFoo2 :: GHC.Prim.Addr# @@ -94,54 +94,54 @@ T10482.$tcFoo :: GHC.Types.TyCon T10482.$tcFoo = GHC.Types.TyCon 3311038889639791302## 7944995683507700778## T10482.$trModule T10482.$tcFoo1 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} -$krep6_r12G :: [GHC.Types.KindRep] +$krep6_r124 :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep6_r12G = GHC.Types.: @GHC.Types.KindRep $krep2_r12C (GHC.Types.[] @GHC.Types.KindRep) +$krep6_r124 = GHC.Types.: @GHC.Types.KindRep $krep2_r120 (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep7_r12H :: GHC.Types.KindRep +$krep7_r125 :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep7_r12H = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep6_r12G +$krep7_r125 = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep6_r124 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep8_r12I :: GHC.Types.KindRep +$krep8_r126 :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep8_r12I = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep3_r12D +$krep8_r126 = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep3_r121 -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} -$krep9_r12J :: [GHC.Types.KindRep] +$krep9_r127 :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep9_r12J = GHC.Types.: @GHC.Types.KindRep $krep5_r12F (GHC.Types.[] @GHC.Types.KindRep) +$krep9_r127 = GHC.Types.: @GHC.Types.KindRep $krep5_r123 (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep10_r12K :: GHC.Types.KindRep +$krep10_r128 :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep10_r12K = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep9_r12J +$krep10_r128 = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep9_r127 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep11_r12L :: GHC.Types.KindRep +$krep11_r129 :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep11_r12L = GHC.Types.KindRepFun $krep8_r12I $krep10_r12K +$krep11_r129 = GHC.Types.KindRepFun $krep8_r126 $krep10_r128 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T10482.$tc'FooPair1 [InlPrag=[~]] :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -T10482.$tc'FooPair1 = GHC.Types.KindRepFun $krep7_r12H $krep11_r12L +T10482.$tc'FooPair1 = GHC.Types.KindRepFun $krep7_r125 $krep11_r129 -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} -$krep12_r12M :: [GHC.Types.KindRep] +$krep12_r12a :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep12_r12M = GHC.Types.: @GHC.Types.KindRep $krep_r12A (GHC.Types.[] @GHC.Types.KindRep) +$krep12_r12a = GHC.Types.: @GHC.Types.KindRep $krep_r11Y (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep13_r12N :: GHC.Types.KindRep +$krep13_r12b :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep13_r12N = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep12_r12M +$krep13_r12b = GHC.Types.KindRepTyConApp T10482.$tcFoo $krep12_r12a -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T10482.$tc'Foo1 [InlPrag=[~]] :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -T10482.$tc'Foo1 = GHC.Types.KindRepFun $krep_r12A $krep13_r12N +T10482.$tc'Foo1 = GHC.Types.KindRepFun $krep_r11Y $krep13_r12b -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T10482.$tc'FooPair3 :: GHC.Prim.Addr# @@ -174,52 +174,61 @@ T10482.$tc'Foo :: GHC.Types.TyCon [GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T10482.$tc'Foo = GHC.Types.TyCon 5096937192618987042## 15136671864408054946## T10482.$trModule T10482.$tc'Foo2 0# T10482.$tc'Foo1 --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl_r12O :: Int -[GblId, Unf=OtherCon []] -lvl_r12O = GHC.Types.I# 0# - Rec { --- RHS size: {terms: 19, types: 5, coercions: 3, joins: 0/0} -T10482.$wfoo [InlPrag=[2], Occ=LoopBreaker] :: Foo Int -> GHC.Prim.Int# -> Int -[GblId, Arity=2, Str=<L,1*U><S,1*U>, Unf=OtherCon []] +-- RHS size: {terms: 19, types: 4, coercions: 0, joins: 0/0} +T10482.$wfoo [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=<ML><1L>, Unf=OtherCon []] T10482.$wfoo - = \ (ww_s11H - :: Foo Int - Unf=OtherCon []) - (ww1_s11O :: GHC.Prim.Int#) -> - case ww1_s11O of wild_X1 { + = \ (ww_s11f :: GHC.Prim.Int#) (ww1_s11s :: GHC.Prim.Int#) -> + case ww1_s11s of wild_X1 { __DEFAULT -> case GHC.Prim.remInt# wild_X1 2# of { - __DEFAULT -> ww_s11H `cast` (T10482.D:R:FooInt0[0] ; T10482.N:R:FooInt[0] :: Foo Int ~R# Int); - 0# -> T10482.$wfoo ww_s11H (GHC.Prim.-# wild_X1 1#) + __DEFAULT -> ww_s11f; + 0# -> T10482.$wfoo ww_s11f (GHC.Prim.-# wild_X1 1#) }; - 0# -> lvl_r12O + 0# -> 0# } end Rec } --- RHS size: {terms: 14, types: 27, coercions: 8, joins: 0/0} +-- RHS size: {terms: 21, types: 30, coercions: 11, joins: 0/0} foo [InlPrag=[2]] :: Foo ((Int, Int), Int) -> Int -> Int [GblId, Arity=2, - Str=<S(SL),1*U(1*U(1*U,A),A)><S(S),1*U(1*U)>, + Str=<1!P(1!P(1!P(ML),1!A),1!A)><1!P(1L)>, + Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w_s11A [Occ=Once1!] :: Foo ((Int, Int), Int)) (w1_s11B [Occ=Once1!] :: Int) -> - case w_s11A `cast` (T10482.D:R:Foo(,)0[0] <(Int, Int)>_N <Int>_N :: Foo ((Int, Int), Int) ~R# T10482.R:Foo(,) (Int, Int) Int) of - { FooPair ww1_s11E [Occ=Once1!] _ [Occ=Dead] -> - case ww1_s11E `cast` (T10482.D:R:Foo(,)0[0] <Int>_N <Int>_N :: Foo (Int, Int) ~R# T10482.R:Foo(,) Int Int) of - { FooPair ww4_s11H [Occ=Once1] _ [Occ=Dead] -> - case w1_s11B of { GHC.Types.I# ww7_s11O [Occ=Once1] -> T10482.$wfoo ww4_s11H ww7_s11O } + Tmpl= \ (w_s118 [Occ=Once1!] :: Foo ((Int, Int), Int)) (w1_s119 [Occ=Once1!] :: Int) -> + case w_s118 `cast` (T10482.D:R:Foo(,)0[0] <(Int, Int)>_N <Int>_N :: Foo ((Int, Int), Int) ~R# T10482.R:Foo(,) (Int, Int) Int) of + { FooPair ww_s11b [Occ=Once1!] _ [Occ=Dead] -> + case ww_s11b `cast` (T10482.D:R:Foo(,)0[0] <Int>_N <Int>_N :: Foo (Int, Int) ~R# T10482.R:Foo(,) Int Int) of + { FooPair ww2_s11d [Occ=Once1!] _ [Occ=Dead] -> + case ww2_s11d + `cast` (T10482.D:R:FooInt0[0] + ; T10482.N:R:FooInt[0] + :: Foo Int ~R# Int) + of + { GHC.Types.I# ww4_s11f [Occ=Once1] -> + case w1_s119 of { GHC.Types.I# ww5_s11s [Occ=Once1] -> + case T10482.$wfoo ww4_s11f ww5_s11s of ww6_s11x [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww6_s11x } + } + } } }}] foo - = \ (w_s11A :: Foo ((Int, Int), Int)) (w1_s11B :: Int) -> - case w_s11A `cast` (T10482.D:R:Foo(,)0[0] <(Int, Int)>_N <Int>_N :: Foo ((Int, Int), Int) ~R# T10482.R:Foo(,) (Int, Int) Int) of - { FooPair ww1_s11E ww2_s11K -> - case ww1_s11E `cast` (T10482.D:R:Foo(,)0[0] <Int>_N <Int>_N :: Foo (Int, Int) ~R# T10482.R:Foo(,) Int Int) of - { FooPair ww4_s12d ww5_s12e -> - case w1_s11B of { GHC.Types.I# ww7_s11O -> T10482.$wfoo ww4_s12d ww7_s11O } + = \ (w_s118 :: Foo ((Int, Int), Int)) (w1_s119 :: Int) -> + case w_s118 `cast` (T10482.D:R:Foo(,)0[0] <(Int, Int)>_N <Int>_N :: Foo ((Int, Int), Int) ~R# T10482.R:Foo(,) (Int, Int) Int) of + { FooPair ww_s11b ww1_s11m -> + case ww_s11b `cast` (T10482.D:R:Foo(,)0[0] <Int>_N <Int>_N :: Foo (Int, Int) ~R# T10482.R:Foo(,) Int Int) of + { FooPair ww2_s11G ww3_s11H -> + case ww2_s11G + `cast` (T10482.D:R:FooInt0[0] + ; T10482.N:R:FooInt[0] + :: Foo Int ~R# Int) + of + { GHC.Types.I# ww4_s11K -> + case w1_s119 of { GHC.Types.I# ww5_s11s -> case T10482.$wfoo ww4_s11K ww5_s11s of ww6_s11x { __DEFAULT -> GHC.Types.I# ww6_s11x } } + } } } diff --git a/testsuite/tests/stranal/should_compile/T10482a.stderr b/testsuite/tests/stranal/should_compile/T10482a.stderr index 51b13f3a3f..e23cb95b72 100644 --- a/testsuite/tests/stranal/should_compile/T10482a.stderr +++ b/testsuite/tests/stranal/should_compile/T10482a.stderr @@ -1,36 +1,36 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 342, types: 152, coercions: 3, joins: 0/0} +Result size of Tidy Core = {terms: 353, types: 153, coercions: 3, joins: 0/0} --- RHS size: {terms: 9, types: 8, coercions: 0, joins: 0/0} +-- RHS size: {terms: 9, types: 7, coercions: 0, joins: 0/0} Foo.$WMkT4 [InlPrag=INLINE[final] CONLIKE] :: forall a. Foo a %1 -> Int %1 -> T4 a [GblId[DataConWrapper], Arity=2, Caf=NoCafRefs, - Str=<S,U><L,U>, - Cpr=m1, + Str=<SL><L>, + Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (@a_agp) (dt_aJ1 [Occ=Once1] :: Foo a_agp) (dt_aJ2 [Occ=Once1] :: Int) -> - case dt_aJ1 of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT4 @a_agp dt_X0 dt_aJ2 }}] + Tmpl= \ (@a_agn) (dt_aJ6 [Occ=Once1] :: Foo a_agn) (dt_aJ7 [Occ=Once1] :: Int) -> + case dt_aJ6 of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT4 @a_agn dt_X0 dt_aJ7 }}] Foo.$WMkT4 - = \ (@a_agp) (dt_aJ1 [Occ=Once1] :: Foo a_agp) (dt_aJ2 [Occ=Once1] :: Int) -> - case dt_aJ1 of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT4 @a_agp dt_X0 dt_aJ2 } + = \ (@a_agn) (dt_aJ6 [Occ=Once1] :: Foo a_agn) (dt_aJ7 [Occ=Once1] :: Int) -> + case dt_aJ6 of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT4 @a_agn dt_X0 dt_aJ7 } -- RHS size: {terms: 8, types: 3, coercions: 0, joins: 0/0} Foo.$WMkT2 [InlPrag=INLINE[final] CONLIKE] :: Int %1 -> Int %1 -> T2 [GblId[DataConWrapper], Arity=2, Caf=NoCafRefs, - Str=<S,U><L,U>, - Cpr=m1, + Str=<SL><L>, + Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (dt_aIj [Occ=Once1] :: Int) (dt_aIk [Occ=Once1] :: Int) -> - case dt_aIj of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT2 dt_X0 dt_aIk }}] + Tmpl= \ (dt_aIl [Occ=Once1] :: Int) (dt_aIm [Occ=Once1] :: Int) -> + case dt_aIl of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT2 dt_X0 dt_aIm }}] Foo.$WMkT2 - = \ (dt_aIj [Occ=Once1] :: Int) (dt_aIk [Occ=Once1] :: Int) -> - case dt_aIj of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT2 dt_X0 dt_aIk } + = \ (dt_aIl [Occ=Once1] :: Int) (dt_aIm [Occ=Once1] :: Int) -> + case dt_aIl of dt_X0 [Occ=Once1] { __DEFAULT -> Foo.MkT2 dt_X0 dt_aIm } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} Foo.$trModule4 :: GHC.Prim.Addr# @@ -58,14 +58,14 @@ Foo.$trModule :: GHC.Types.Module Foo.$trModule = GHC.Types.Module Foo.$trModule3 Foo.$trModule1 -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} -$krep_rSS :: GHC.Types.KindRep +$krep_rPk :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep_rSS = GHC.Types.KindRepTyConApp GHC.Types.$tcInt (GHC.Types.[] @GHC.Types.KindRep) +$krep_rPk = GHC.Types.KindRepTyConApp GHC.Types.$tcInt (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -$krep1_rST :: GHC.Types.KindRep +$krep1_rPl :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep1_rST = GHC.Types.KindRepVar 0# +$krep1_rPl = GHC.Types.KindRepVar 0# -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} Foo.$tcT5 :: GHC.Prim.Addr# @@ -83,19 +83,19 @@ Foo.$tcT2 :: GHC.Types.TyCon Foo.$tcT2 = GHC.Types.TyCon 12492463661685256209## 1082997131366389398## Foo.$trModule Foo.$tcT1 0# GHC.Types.krep$* -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} -$krep2_rSU :: GHC.Types.KindRep +$krep2_rPm :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep2_rSU = GHC.Types.KindRepTyConApp Foo.$tcT2 (GHC.Types.[] @GHC.Types.KindRep) +$krep2_rPm = GHC.Types.KindRepTyConApp Foo.$tcT2 (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep3_rSV :: GHC.Types.KindRep +$krep3_rPn :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep3_rSV = GHC.Types.KindRepFun $krep_rSS $krep2_rSU +$krep3_rPn = GHC.Types.KindRepFun $krep_rPk $krep2_rPm -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Foo.$tc'MkT1 [InlPrag=[~]] :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -Foo.$tc'MkT1 = GHC.Types.KindRepFun $krep_rSS $krep3_rSV +Foo.$tc'MkT1 = GHC.Types.KindRepFun $krep_rPk $krep3_rPn -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} Foo.$tc'MkT6 :: GHC.Prim.Addr# @@ -128,19 +128,19 @@ Foo.$tcT3 :: GHC.Types.TyCon Foo.$tcT3 = GHC.Types.TyCon 8915518733037212359## 16476420519216613869## Foo.$trModule Foo.$tcT6 0# GHC.Types.krep$* -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} -$krep4_rSW :: GHC.Types.KindRep +$krep4_rPo :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep4_rSW = GHC.Types.KindRepTyConApp Foo.$tcT3 (GHC.Types.[] @GHC.Types.KindRep) +$krep4_rPo = GHC.Types.KindRepTyConApp Foo.$tcT3 (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep5_rSX :: GHC.Types.KindRep +$krep5_rPp :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep5_rSX = GHC.Types.KindRepFun $krep_rSS $krep4_rSW +$krep5_rPp = GHC.Types.KindRepFun $krep_rPk $krep4_rPo -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Foo.$tc'MkT7 [InlPrag=[~]] :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -Foo.$tc'MkT7 = GHC.Types.KindRepFun $krep_rSS $krep5_rSX +Foo.$tc'MkT7 = GHC.Types.KindRepFun $krep_rPk $krep5_rPp -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} Foo.$tc'MkT9 :: GHC.Prim.Addr# @@ -163,29 +163,29 @@ Foo.$tcFoo :: GHC.Types.TyCon Foo.$tcFoo = GHC.Types.TyCon 11236787750777559483## 2472662601374496863## Foo.$trModule Foo.$trModule1 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} -$krep6_rSY :: [GHC.Types.KindRep] +$krep6_rPq :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep6_rSY = GHC.Types.: @GHC.Types.KindRep $krep1_rST (GHC.Types.[] @GHC.Types.KindRep) +$krep6_rPq = GHC.Types.: @GHC.Types.KindRep $krep1_rPl (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep7_rSZ :: GHC.Types.KindRep +$krep7_rPr :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep7_rSZ = GHC.Types.KindRepTyConApp Foo.$tcFoo $krep6_rSY +$krep7_rPr = GHC.Types.KindRepTyConApp Foo.$tcFoo $krep6_rPq -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} -$krep8_rT0 :: [GHC.Types.KindRep] +$krep8_rPs :: [GHC.Types.KindRep] [GblId, Unf=OtherCon []] -$krep8_rT0 = GHC.Types.: @GHC.Types.KindRep $krep_rSS (GHC.Types.[] @GHC.Types.KindRep) +$krep8_rPs = GHC.Types.: @GHC.Types.KindRep $krep_rPk (GHC.Types.[] @GHC.Types.KindRep) -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep9_rT1 :: GHC.Types.KindRep +$krep9_rPt :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep9_rT1 = GHC.Types.KindRepTyConApp Foo.$tcFoo $krep8_rT0 +$krep9_rPt = GHC.Types.KindRepTyConApp Foo.$tcFoo $krep8_rPs -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Foo.$tc'Foo1 [InlPrag=[~]] :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -Foo.$tc'Foo1 = GHC.Types.KindRepFun $krep_rSS $krep9_rT1 +Foo.$tc'Foo1 = GHC.Types.KindRepFun $krep_rPk $krep9_rPt -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} Foo.$tc'Foo3 :: GHC.Prim.Addr# @@ -218,19 +218,19 @@ Foo.$tcT4 :: GHC.Types.TyCon Foo.$tcT4 = GHC.Types.TyCon 15961711399118996930## 13694522307176382499## Foo.$trModule Foo.$tcT8 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep10_rT2 :: GHC.Types.KindRep +$krep10_rPu :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep10_rT2 = GHC.Types.KindRepTyConApp Foo.$tcT4 $krep6_rSY +$krep10_rPu = GHC.Types.KindRepTyConApp Foo.$tcT4 $krep6_rPq -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -$krep11_rT3 :: GHC.Types.KindRep +$krep11_rPv :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -$krep11_rT3 = GHC.Types.KindRepFun $krep_rSS $krep10_rT2 +$krep11_rPv = GHC.Types.KindRepFun $krep_rPk $krep10_rPu -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Foo.$tc'MkT10 [InlPrag=[~]] :: GHC.Types.KindRep [GblId, Unf=OtherCon []] -Foo.$tc'MkT10 = GHC.Types.KindRepFun $krep7_rSZ $krep11_rT3 +Foo.$tc'MkT10 = GHC.Types.KindRepFun $krep7_rPr $krep11_rPv -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} Foo.$tc'MkT12 :: GHC.Prim.Addr# @@ -248,82 +248,100 @@ Foo.$tc'MkT4 :: GHC.Types.TyCon Foo.$tc'MkT4 = GHC.Types.TyCon 6077781708614236332## 14823286043222481570## Foo.$trModule Foo.$tc'MkT11 1# Foo.$tc'MkT10 Rec { --- RHS size: {terms: 14, types: 4, coercions: 3, joins: 0/0} -Foo.$wf4 [InlPrag=[2], Occ=LoopBreaker] :: Foo Int -> GHC.Prim.Int# -> Int -[GblId, Arity=2, Str=<S,1*U><L,U>, Unf=OtherCon []] +-- RHS size: {terms: 14, types: 3, coercions: 0, joins: 0/0} +Foo.$wf4 [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=<1L><L>, Unf=OtherCon []] Foo.$wf4 - = \ (ww_sPs - :: Foo Int - Unf=OtherCon []) - (ww1_sPw :: GHC.Prim.Int#) -> - case GHC.Prim.># ww1_sPw 0# of { - __DEFAULT -> ww_sPs `cast` (Foo.D:R:FooInt0[0] ; Foo.N:R:FooInt[0] :: Foo Int ~R# Int); - 1# -> Foo.$wf4 ww_sPs (GHC.Prim.-# ww1_sPw 1#) + = \ (ww_sNE :: GHC.Prim.Int#) (ww1_sNI :: GHC.Prim.Int#) -> + case GHC.Prim.># ww1_sNI 0# of { + __DEFAULT -> ww_sNE; + 1# -> Foo.$wf4 ww_sNE (GHC.Prim.-# ww1_sNI 1#) } end Rec } --- RHS size: {terms: 10, types: 9, coercions: 0, joins: 0/0} +-- RHS size: {terms: 17, types: 12, coercions: 3, joins: 0/0} f4 [InlPrag=[2]] :: T4 Int -> Int [GblId, Arity=1, - Str=<S(SS),1*U(1*U,1*U(U))>, + Str=<1!P(1!P(1L),1!P(L))>, + 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= \ (w_sPp [Occ=Once1!] :: T4 Int) -> - case w_sPp of { MkT4 ww1_sPs [Occ=Once1] ww2_sPt [Occ=Once1!] -> - case ww2_sPt of { GHC.Types.I# ww4_sPw [Occ=Once1] -> Foo.$wf4 ww1_sPs ww4_sPw } + Tmpl= \ (w_sNA [Occ=Once1!] :: T4 Int) -> + case w_sNA of { MkT4 ww_sNC [Occ=Once1!] ww1_sNG [Occ=Once1!] -> + case ww_sNC + `cast` (Foo.D:R:FooInt0[0] + ; Foo.N:R:FooInt[0] + :: Foo Int ~R# Int) + of + { GHC.Types.I# ww2_sNE [Occ=Once1] -> + case ww1_sNG of { GHC.Types.I# ww3_sNI [Occ=Once1] -> + case Foo.$wf4 ww2_sNE ww3_sNI of ww4_sOx [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww4_sOx } + } + } }}] f4 - = \ (w_sPp :: T4 Int) -> - case w_sPp of { MkT4 ww1_sPs ww2_sPt -> case ww2_sPt of { GHC.Types.I# ww4_sPw -> Foo.$wf4 ww1_sPs ww4_sPw } } - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl_rT4 :: Int -[GblId, Unf=OtherCon []] -lvl_rT4 = GHC.Types.I# 1# + = \ (w_sNA :: T4 Int) -> + case w_sNA of { MkT4 ww_sNC ww1_sNG -> + case ww_sNC + `cast` (Foo.D:R:FooInt0[0] + ; Foo.N:R:FooInt[0] + :: Foo Int ~R# Int) + of + { GHC.Types.I# ww2_sOP -> + case ww1_sNG of { GHC.Types.I# ww3_sNI -> case Foo.$wf4 ww2_sOP ww3_sNI of ww4_sOx { __DEFAULT -> GHC.Types.I# ww4_sOx } } + } + } Rec { -- RHS size: {terms: 21, types: 4, coercions: 0, joins: 0/0} -Foo.$wf2 [InlPrag=[2], Occ=LoopBreaker] :: Int -> GHC.Prim.Int# -> Int -[GblId, Arity=2, Str=<L,1*U><L,U>, Unf=OtherCon []] +Foo.$wf2 [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=<ML><L>, Unf=OtherCon []] Foo.$wf2 - = \ (ww_sPD - :: Int - Unf=OtherCon []) - (ww1_sPH :: GHC.Prim.Int#) -> - case GHC.Prim.># ww1_sPH 0# of { + = \ (ww_sNS :: GHC.Prim.Int#) (ww1_sNW :: GHC.Prim.Int#) -> + case GHC.Prim.># ww1_sNW 0# of { __DEFAULT -> - case GHC.Prim.># ww1_sPH 1# of { - __DEFAULT -> ww_sPD; - 1# -> lvl_rT4 + case GHC.Prim.># ww1_sNW 1# of { + __DEFAULT -> ww_sNS; + 1# -> 1# }; - 1# -> Foo.$wf2 ww_sPD (GHC.Prim.-# ww1_sPH 1#) + 1# -> Foo.$wf2 ww_sNS (GHC.Prim.-# ww1_sNW 1#) } end Rec } --- RHS size: {terms: 10, types: 6, coercions: 0, joins: 0/0} +-- RHS size: {terms: 17, types: 9, coercions: 0, joins: 0/0} f2 [InlPrag=[2]] :: T2 -> Int [GblId, Arity=1, - Str=<S(LS),1*U(1*U,1*U(U))>, + Str=<1!P(1!P(ML),1!P(L))>, + 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= \ (w_sPA [Occ=Once1!] :: T2) -> - case w_sPA of { MkT2 ww1_sPD [Occ=Once1] ww2_sPE [Occ=Once1!] -> - case ww2_sPE of { GHC.Types.I# ww4_sPH [Occ=Once1] -> Foo.$wf2 ww1_sPD ww4_sPH } + Tmpl= \ (w_sNO [Occ=Once1!] :: T2) -> + case w_sNO of { MkT2 ww_sNQ [Occ=Once1!] ww1_sNU [Occ=Once1!] -> + case ww_sNQ of { GHC.Types.I# ww2_sNS [Occ=Once1] -> + case ww1_sNU of { GHC.Types.I# ww3_sNW [Occ=Once1] -> + case Foo.$wf2 ww2_sNS ww3_sNW of ww4_sOz [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww4_sOz } + } + } }}] f2 - = \ (w_sPA :: T2) -> case w_sPA of { MkT2 ww1_sPD ww2_sPE -> case ww2_sPE of { GHC.Types.I# ww4_sPH -> Foo.$wf2 ww1_sPD ww4_sPH } } + = \ (w_sNO :: T2) -> + case w_sNO of { MkT2 ww_sNQ ww1_sNU -> + case ww_sNQ of { GHC.Types.I# ww2_sOS -> + case ww1_sNU of { GHC.Types.I# ww3_sNW -> case Foo.$wf2 ww2_sOS ww3_sNW of ww4_sOz { __DEFAULT -> GHC.Types.I# ww4_sOz } } + } + } Rec { -- RHS size: {terms: 15, types: 4, coercions: 0, joins: 0/0} Foo.$wh [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> Bool -[GblId, Arity=2, Str=<S,1*U><L,U>, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L><L>, Unf=OtherCon []] Foo.$wh - = \ (ww_sPP :: GHC.Prim.Int#) (ww1_sPT :: GHC.Prim.Int#) -> - case ww_sPP of ds_X2 { - __DEFAULT -> Foo.$wh (GHC.Prim.-# ds_X2 1#) ww1_sPT; - 0# -> GHC.Prim.tagToEnum# @Bool (GHC.Prim.># ww1_sPT 0#) + = \ (ww_sO5 :: GHC.Prim.Int#) (ww1_sO8 :: GHC.Prim.Int#) -> + case ww_sO5 of ds_X2 { + __DEFAULT -> Foo.$wh (GHC.Prim.-# ds_X2 1#) ww1_sO8; + 0# -> GHC.Prim.tagToEnum# @Bool (GHC.Prim.># ww1_sO8 0#) } end Rec } @@ -331,25 +349,23 @@ end Rec } h [InlPrag=[2]] :: Int -> Int -> Bool [GblId, Arity=2, - Str=<S(S),1*U(1*U)><S,1*U(U)>, + Str=<1!P(1L)><1!P(L)>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w_sPL [Occ=Once1!] :: Int) (w1_sPM [Occ=Once1!] :: Int) -> - case w_sPL of { GHC.Types.I# ww1_sPP [Occ=Once1] -> - case w1_sPM of { GHC.Types.I# ww3_sPT [Occ=Once1] -> Foo.$wh ww1_sPP ww3_sPT } - }}] -h = \ (w_sPL :: Int) (w1_sPM :: Int) -> - case w_sPL of { GHC.Types.I# ww1_sPP -> case w1_sPM of { GHC.Types.I# ww3_sPT -> Foo.$wh ww1_sPP ww3_sPT } } + Tmpl= \ (w_sO2 [Occ=Once1!] :: Int) (w1_sO3 [Occ=Once1!] :: Int) -> + case w_sO2 of { GHC.Types.I# ww_sO5 [Occ=Once1] -> case w1_sO3 of { GHC.Types.I# ww1_sO8 [Occ=Once1] -> Foo.$wh ww_sO5 ww1_sO8 } }}] +h = \ (w_sO2 :: Int) (w1_sO3 :: Int) -> + case w_sO2 of { GHC.Types.I# ww_sO5 -> case w1_sO3 of { GHC.Types.I# ww1_sO8 -> Foo.$wh ww_sO5 ww1_sO8 } } Rec { -- RHS size: {terms: 12, types: 2, coercions: 0, joins: 0/0} Foo.$wf1 [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=1, Str=<S,U>, Unf=OtherCon []] +[GblId, Arity=1, Str=<SL>, Unf=OtherCon []] Foo.$wf1 - = \ (ww_sPZ :: GHC.Prim.Int#) -> - case Foo.$wh ww_sPZ ww_sPZ of { - False -> Foo.$wf1 (GHC.Prim.-# ww_sPZ 1#); - True -> ww_sPZ + = \ (ww_sOe :: GHC.Prim.Int#) -> + case Foo.$wh ww_sOe ww_sOe of { + False -> Foo.$wf1 (GHC.Prim.-# ww_sOe 1#); + True -> ww_sOe } end Rec } @@ -357,27 +373,26 @@ end Rec } f1 [InlPrag=[2]] :: Int -> Int [GblId, Arity=1, - Str=<S(S),1*U(U)>, - Cpr=m1, + Str=<1!P(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= \ (w_sPW [Occ=Once1!] :: Int) -> - case w_sPW of { GHC.Types.I# ww1_sPZ [Occ=Once1] -> - case Foo.$wf1 ww1_sPZ of ww2_sQ3 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww2_sQ3 } + Tmpl= \ (w_sOc [Occ=Once1!] :: Int) -> + case w_sOc of { GHC.Types.I# ww_sOe [Occ=Once1] -> + case Foo.$wf1 ww_sOe of ww1_sOB [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww1_sOB } }}] f1 - = \ (w_sPW :: Int) -> - case w_sPW of { GHC.Types.I# ww1_sPZ -> case Foo.$wf1 ww1_sPZ of ww2_sQ3 { __DEFAULT -> GHC.Types.I# ww2_sQ3 } } + = \ (w_sOc :: Int) -> case w_sOc of { GHC.Types.I# ww_sOe -> case Foo.$wf1 ww_sOe of ww1_sOB { __DEFAULT -> GHC.Types.I# ww1_sOB } } Rec { -- RHS size: {terms: 14, types: 3, coercions: 0, joins: 0/0} Foo.$wf3 [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=2, Str=<S,U><L,U>, Unf=OtherCon []] +[GblId, Arity=2, Str=<SL><L>, Unf=OtherCon []] Foo.$wf3 - = \ (ww_sQb :: GHC.Prim.Int#) (ww1_sQg :: GHC.Prim.Int#) -> - case Foo.$wh ww_sQb ww1_sQg of { - False -> ww_sQb; - True -> Foo.$wf3 ww_sQb (GHC.Prim.-# ww1_sQg 1#) + = \ (ww_sOn :: GHC.Prim.Int#) (ww1_sOr :: GHC.Prim.Int#) -> + case Foo.$wh ww_sOn ww1_sOr of { + False -> ww_sOn; + True -> Foo.$wf3 ww_sOn (GHC.Prim.-# ww1_sOr 1#) } end Rec } @@ -385,23 +400,23 @@ end Rec } f3 [InlPrag=[2]] :: T3 -> Int [GblId, Arity=1, - Str=<S(S(S)S),1*U(1*U(U),1*U(U))>, - Cpr=m1, + Str=<1!P(1!P(SL),1!P(L))>, + 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= \ (w_sQ5 [Occ=Once1!] :: T3) -> - case w_sQ5 of { MkT3 ww1_sQ8 [Occ=Once1!] ww2_sQd [Occ=Once1!] -> - case ww1_sQ8 of { GHC.Types.I# ww4_sQb [Occ=Once1] -> - case ww2_sQd of { GHC.Types.I# ww6_sQg [Occ=Once1] -> - case Foo.$wf3 ww4_sQb ww6_sQg of ww7_sQl [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww7_sQl } + Tmpl= \ (w_sOj [Occ=Once1!] :: T3) -> + case w_sOj of { MkT3 ww_sOl [Occ=Once1!] ww1_sOp [Occ=Once1!] -> + case ww_sOl of { GHC.Types.I# ww2_sOn [Occ=Once1] -> + case ww1_sOp of { GHC.Types.I# ww3_sOr [Occ=Once1] -> + case Foo.$wf3 ww2_sOn ww3_sOr of ww4_sOD [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww4_sOD } } } }}] f3 - = \ (w_sQ5 :: T3) -> - case w_sQ5 of { MkT3 ww1_sQ8 ww2_sQd -> - case ww1_sQ8 of { GHC.Types.I# ww4_sQb -> - case ww2_sQd of { GHC.Types.I# ww6_sQg -> case Foo.$wf3 ww4_sQb ww6_sQg of ww7_sQl { __DEFAULT -> GHC.Types.I# ww7_sQl } } + = \ (w_sOj :: T3) -> + case w_sOj of { MkT3 ww_sOl ww1_sOp -> + case ww_sOl of { GHC.Types.I# ww2_sOn -> + case ww1_sOp of { GHC.Types.I# ww3_sOr -> case Foo.$wf3 ww2_sOn ww3_sOr of ww4_sOD { __DEFAULT -> GHC.Types.I# ww4_sOD } } } } diff --git a/testsuite/tests/stranal/should_compile/T10694.stderr b/testsuite/tests/stranal/should_compile/T10694.stderr index 481c350fc2..e809998142 100644 --- a/testsuite/tests/stranal/should_compile/T10694.stderr +++ b/testsuite/tests/stranal/should_compile/T10694.stderr @@ -4,17 +4,17 @@ Result size of Tidy Core = {terms: 74, types: 65, coercions: 0, joins: 0/4} -- RHS size: {terms: 39, types: 25, coercions: 0, joins: 0/4} T10694.$wpm [InlPrag=NOINLINE] :: Int -> Int -> (# Int, Int #) -[GblId, Arity=2, Str=<LP(L)><LP(L)>, Unf=OtherCon []] +[GblId, Arity=2, Str=<L><L>, Unf=OtherCon []] T10694.$wpm - = \ (w :: Int) (w1 :: Int) -> + = \ (x :: Int) (y :: Int) -> let { l :: Int [LclId] - l = case w of { GHC.Types.I# x -> case w1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } } } in + l = case x of { GHC.Types.I# x1 -> case y of { GHC.Types.I# y1 -> GHC.Types.I# (GHC.Prim.+# x1 y1) } } } in let { l1 :: Int [LclId] - l1 = case w of { GHC.Types.I# x -> case w1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.-# x y) } } } in + l1 = case x of { GHC.Types.I# x1 -> case y of { GHC.Types.I# y1 -> GHC.Types.I# (GHC.Prim.-# x1 y1) } } } in let { l2 :: [Int] [LclId, Unf=OtherCon []] @@ -29,23 +29,21 @@ T10694.$wpm pm [InlPrag=[final]] :: Int -> Int -> (Int, Int) [GblId, Arity=2, - Str=<LP(L)><LP(L)>, + Str=<L><L>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once1] :: Int) (w1 [Occ=Once1] :: Int) -> - case T10694.$wpm w w1 of { (# ww1 [Occ=Once1], ww2 [Occ=Once1] #) -> (ww1, ww2) }}] -pm = \ (w :: Int) (w1 :: Int) -> case T10694.$wpm w w1 of { (# ww1, ww2 #) -> (ww1, ww2) } + Tmpl= \ (x [Occ=Once1] :: Int) (y [Occ=Once1] :: Int) -> + case T10694.$wpm x y of { (# ww [Occ=Once1], ww1 [Occ=Once1] #) -> (ww, ww1) }}] +pm = \ (x :: Int) (y :: Int) -> case T10694.$wpm x y of { (# ww, ww1 #) -> (ww, ww1) } -- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} m :: Int -> Int -> Int [GblId, Arity=2, - Str=<LP(L)><LP(L)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once1] :: Int) (y [Occ=Once1] :: Int) -> case pm x y of { (_ [Occ=Dead], mr [Occ=Once1]) -> mr }}] -m = \ (x :: Int) (y :: Int) -> case T10694.$wpm x y of { (# ww1, ww2 #) -> ww2 } + Str=<L><L>, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 40 0}] +m = \ (x :: Int) (y :: Int) -> case T10694.$wpm x y of { (# ww, ww1 #) -> ww1 } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T10694.$trModule4 :: GHC.Prim.Addr# diff --git a/testsuite/tests/stranal/should_compile/T18894.stderr b/testsuite/tests/stranal/should_compile/T18894.stderr index 3d3ff81440..55fbd59939 100644 --- a/testsuite/tests/stranal/should_compile/T18894.stderr +++ b/testsuite/tests/stranal/should_compile/T18894.stderr @@ -1,7 +1,7 @@ ==================== Demand analysis ==================== Result size of Demand analysis - = {terms: 195, types: 95, coercions: 0, joins: 0/2} + = {terms: 189, types: 95, coercions: 0, joins: 0/2} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# @@ -45,18 +45,18 @@ lvl :: Int WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# --- RHS size: {terms: 45, types: 15, coercions: 0, joins: 0/1} -g2 [InlPrag=NOINLINE, Dmd=LCL(C1(P(MP(L),1P(L))))] +-- RHS size: {terms: 42, types: 15, coercions: 0, joins: 0/1} +g2 [InlPrag=NOINLINE, Dmd=LCL(C1(!P(M!L,1!L)))] :: Int -> Int -> (Int, Int) [LclId, Arity=2, - Str=<LP(L)><1P(1L)>, + Str=<L><1!P(1L)>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 20] 126 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 20] 106 20}] g2 - = \ (m [Dmd=LP(L)] :: Int) (ds [Dmd=1P(1L)] :: Int) -> + = \ (m :: Int) (ds [Dmd=1!P(1L)] :: Int) -> case ds of { GHC.Types.I# ds [Dmd=1L] -> - case ds of ds [Dmd=ML] { + case ds of ds [Dmd=M!L] { __DEFAULT -> (case m of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.*# 2# y) }, case ds of wild { @@ -71,7 +71,6 @@ g2 { __DEFAULT -> GHC.Types.I# (GHC.Prim.-# wild c1#) }; - -1# -> GHC.Types.I# -2#; 0# -> GHC.Real.divZeroError @Int }); 1# -> (m, lvl) @@ -103,19 +102,19 @@ lvl = GHC.Types.I# 0# h2 :: Int -> Int [LclIdX, Arity=1, - Str=<1P(SL)>, + Str=<1!P(SL)>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 162 10}] h2 - = \ (ds [Dmd=1P(SL)] :: Int) -> - case ds of wild [Dmd=LP(L)] { GHC.Types.I# ds [Dmd=SL] -> - case ds of ds { + = \ (ds [Dmd=1!P(SL)] :: Int) -> + case ds of wild [Dmd=L!L] { GHC.Types.I# ds [Dmd=SL] -> + case ds of ds [Dmd=L!L] { __DEFAULT -> case GHC.Prim.remInt# ds 2# of { __DEFAULT -> - case g2 wild lvl of { (ds1 [Dmd=A], y [Dmd=1L]) -> y }; + case g2 wild lvl of { (ds1 [Dmd=A], y [Dmd=1!L]) -> y }; 0# -> - case g2 lvl wild of { (x [Dmd=1P(L)], ds [Dmd=1P(L)]) -> + case g2 lvl wild of { (x [Dmd=1!L], ds [Dmd=1!L]) -> case x of { GHC.Types.I# x -> case ds of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } } @@ -146,17 +145,17 @@ lvl :: (Int, Int) WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] lvl = (lvl, lvl) --- RHS size: {terms: 39, types: 10, coercions: 0, joins: 0/1} -g1 [InlPrag=NOINLINE, Dmd=LCL(P(LP(L),LP(L)))] :: Int -> (Int, Int) +-- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} +g1 [InlPrag=NOINLINE, Dmd=LCL(!P(L!L,L!L))] :: Int -> (Int, Int) [LclId, Arity=1, - Str=<1P(1L)>, + Str=<1!P(1L)>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 106 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 86 10}] g1 - = \ (ds [Dmd=1P(1L)] :: Int) -> + = \ (ds [Dmd=1!P(1L)] :: Int) -> case ds of { GHC.Types.I# ds [Dmd=1L] -> - case ds of ds { + case ds of ds [Dmd=L!L] { __DEFAULT -> (GHC.Types.I# (GHC.Prim.*# 2# ds), case ds of wild { @@ -171,7 +170,6 @@ g1 { __DEFAULT -> GHC.Types.I# (GHC.Prim.-# wild c1#) }; - -1# -> GHC.Types.I# -2#; 0# -> GHC.Real.divZeroError @Int }); 1# -> lvl @@ -196,21 +194,21 @@ lvl = g1 (GHC.Types.I# 2#) h1 :: Int -> Int [LclIdX, Arity=1, - Str=<1P(SL)>, + Str=<1!P(SL)>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 111 10}] h1 - = \ (ds [Dmd=1P(SL)] :: Int) -> - case ds of wild [Dmd=MP(ML)] { GHC.Types.I# ds [Dmd=SL] -> + = \ (ds [Dmd=1!P(SL)] :: Int) -> + case ds of wild [Dmd=M!P(M!L)] { GHC.Types.I# ds [Dmd=SL] -> case ds of { __DEFAULT -> - case g1 wild of { (x [Dmd=1P(L)], ds [Dmd=1P(L)]) -> + case g1 wild of { (x [Dmd=1!L], ds [Dmd=1!L]) -> case x of { GHC.Types.I# x -> case ds of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } } }; 1# -> lvl; - 2# -> case lvl of { (ds1 [Dmd=A], y [Dmd=1L]) -> y } + 2# -> case lvl of { (ds1 [Dmd=A], y [Dmd=1!L]) -> y } } } @@ -219,7 +217,7 @@ h1 ==================== Demand analysis ==================== Result size of Demand analysis - = {terms: 183, types: 115, coercions: 0, joins: 0/2} + = {terms: 176, types: 114, coercions: 0, joins: 0/2} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# @@ -263,26 +261,19 @@ lvl :: Int WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# --- 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# -2# - --- RHS size: {terms: 41, types: 17, coercions: 0, joins: 0/1} -$wg2 [InlPrag=NOINLINE, Dmd=LCL(C1(P(MP(L),1P(L))))] +-- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} +$wg2 [InlPrag=NOINLINE, Dmd=LCL(C1(!P(M!L,1!L)))] :: Int -> GHC.Prim.Int# -> (# Int, Int #) [LclId, Arity=2, - Str=<LP(L)><1L>, + Str=<L><1L>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 30] 86 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 30] 76 20}] $wg2 - = \ (w [Dmd=LP(L)] :: Int) (ww [Dmd=1L] :: GHC.Prim.Int#) -> - case ww of ds [Dmd=ML] { + = \ (m :: Int) (ww [Dmd=1L] :: GHC.Prim.Int#) -> + case ww of ds [Dmd=M!L] { __DEFAULT -> - (# case w of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.*# 2# y) }, + (# case m of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.*# 2# y) }, case ds of wild { __DEFAULT -> let { @@ -295,10 +286,9 @@ $wg2 { __DEFAULT -> GHC.Types.I# (GHC.Prim.-# wild c1#) }; - -1# -> lvl; 0# -> GHC.Real.divZeroError @Int } #); - 1# -> (# w, lvl #) + 1# -> (# m, lvl #) } -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} @@ -309,7 +299,7 @@ lvl :: Int lvl = GHC.Types.I# 2# -- RHS size: {terms: 34, types: 21, coercions: 0, joins: 0/0} -$wh2 [InlPrag=[2]] :: GHC.Prim.Int# -> Int +$wh2 [InlPrag=[2], Dmd=LCL(!L)] :: GHC.Prim.Int# -> Int [LclId, Arity=1, Str=<1L>, @@ -317,16 +307,16 @@ $wh2 [InlPrag=[2]] :: GHC.Prim.Int# -> Int WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 162 10}] $wh2 = \ (ww [Dmd=1L] :: GHC.Prim.Int#) -> - case ww of ds { + case ww of ds [Dmd=L!L] { __DEFAULT -> case GHC.Prim.remInt# ds 2# of { __DEFAULT -> case $wg2 (GHC.Types.I# ds) 2# of - { (# ww [Dmd=A], ww [Dmd=1L] #) -> + { (# ww [Dmd=A], ww [Dmd=1!L] #) -> ww }; 0# -> - case $wg2 lvl ds of { (# ww [Dmd=1P(L)], ww [Dmd=1P(L)] #) -> + case $wg2 lvl ds of { (# ww [Dmd=1!L], ww [Dmd=1!L] #) -> case ww of { GHC.Types.I# x -> case ww of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } } @@ -339,27 +329,27 @@ $wh2 h2 [InlPrag=[2]] :: Int -> Int [LclIdX, Arity=1, - Str=<1P(1L)>, + Str=<1!P(1L)>, 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= \ (w [Occ=Once1!, Dmd=1P(SL)] :: Int) -> - case w of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> $wh2 ww }}] + Tmpl= \ (ds [Occ=Once1!, Dmd=S!P(SL)] :: Int) -> + case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> $wh2 ww }}] h2 - = \ (w [Dmd=1P(1L)] :: Int) -> - case w of { GHC.Types.I# ww [Dmd=1L] -> $wh2 ww } + = \ (ds [Dmd=1!P(1L)] :: Int) -> + case ds of { GHC.Types.I# ww [Dmd=1L] -> $wh2 ww } --- RHS size: {terms: 36, types: 14, coercions: 0, joins: 0/1} -$wg1 [InlPrag=NOINLINE, Dmd=LCL(P(L,LP(L)))] +-- RHS size: {terms: 34, types: 14, coercions: 0, joins: 0/1} +$wg1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L!L))] :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) [LclId, Arity=1, Str=<1L>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 66 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 56 20}] $wg1 = \ (ww [Dmd=1L] :: GHC.Prim.Int#) -> - case ww of ds { + case ww of ds [Dmd=L!L] { __DEFAULT -> (# GHC.Prim.*# 2# ds, case ds of wild { @@ -374,7 +364,6 @@ $wg1 { __DEFAULT -> GHC.Types.I# (GHC.Prim.-# wild c1#) }; - -1# -> lvl; 0# -> GHC.Real.divZeroError @Int } #); 1# -> (# 15#, lvl #) @@ -388,7 +377,7 @@ lvl :: (Int, Int) lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} -$wh1 [InlPrag=[2]] :: GHC.Prim.Int# -> Int +$wh1 [InlPrag=[2], Dmd=LCL(!L)] :: GHC.Prim.Int# -> Int [LclId, Arity=1, Str=<1L>, @@ -396,28 +385,28 @@ $wh1 [InlPrag=[2]] :: GHC.Prim.Int# -> Int WorkFree=True, Expandable=True, Guidance=IF_ARGS [50] 91 10}] $wh1 = \ (ww [Dmd=1L] :: GHC.Prim.Int#) -> - case ww of ds [Dmd=ML] { + case ww of ds [Dmd=M!L] { __DEFAULT -> - case $wg1 ds of { (# ww, ww [Dmd=1P(L)] #) -> + case $wg1 ds of { (# ww, ww [Dmd=1!L] #) -> case ww of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# ww y) } }; 1# -> lvl; - 2# -> case lvl of { (ds1 [Dmd=A], y [Dmd=1L]) -> y } + 2# -> case lvl of { (ds1 [Dmd=A], y [Dmd=1!L]) -> y } } -- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0} h1 [InlPrag=[2]] :: Int -> Int [LclIdX, Arity=1, - Str=<1P(1L)>, + Str=<1!P(1L)>, 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= \ (w [Occ=Once1!, Dmd=1P(SL)] :: Int) -> - case w of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> $wh1 ww }}] + Tmpl= \ (ds [Occ=Once1!, Dmd=S!P(SL)] :: Int) -> + case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> $wh1 ww }}] h1 - = \ (w [Dmd=1P(1L)] :: Int) -> - case w of { GHC.Types.I# ww [Dmd=1L] -> $wh1 ww } + = \ (ds [Dmd=1!P(1L)] :: Int) -> + case ds of { GHC.Types.I# ww [Dmd=1L] -> $wh1 ww } diff --git a/testsuite/tests/stranal/should_compile/T18903.stderr b/testsuite/tests/stranal/should_compile/T18903.stderr index 63e95ea124..8c0427b235 100644 --- a/testsuite/tests/stranal/should_compile/T18903.stderr +++ b/testsuite/tests/stranal/should_compile/T18903.stderr @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 88, types: 52, coercions: 0, joins: 0/2} + = {terms: 83, types: 50, coercions: 0, joins: 0/2} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18903.$trModule4 :: GHC.Prim.Addr# @@ -46,66 +46,49 @@ T18903.h1 :: Int WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18903.h1 = GHC.Types.I# 0# --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T18903.h2 :: Int -[GblId, - Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] -T18903.h2 = GHC.Types.I# -2# - --- RHS size: {terms: 60, types: 38, coercions: 0, joins: 0/2} -T18903.$wh [InlPrag=[2]] :: GHC.Prim.Int# -> Int +-- RHS size: {terms: 65, types: 42, coercions: 0, joins: 0/2} +h :: Int -> Int [GblId, Arity=1, - Str=<SL>, + Str=<1!P(SL)>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [70] 197 10}] -T18903.$wh - = \ (ww :: GHC.Prim.Int#) -> + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 217 10}] +h = \ (m :: Int) -> + case m of wild { GHC.Types.I# ds -> let { - $wg [InlPrag=NOINLINE, Dmd=MCM(P(L,1P(L)))] - :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) + $wg [InlPrag=NOINLINE, Dmd=MCM(!P(M!L,1!L))] + :: GHC.Prim.Int# -> (# Int, Int #) [LclId, Arity=1, Str=<1L>, Unf=OtherCon []] $wg - = \ (ww1 [OS=OneShot] :: GHC.Prim.Int#) -> - case ww1 of ds { + = \ (ww [OS=OneShot] :: GHC.Prim.Int#) -> + case ww of ds1 { __DEFAULT -> - (# GHC.Prim.*# 2# ds, - case ds of wild { + (# GHC.Types.I# (GHC.Prim.*# 2# ds1), + case ds1 of wild1 { __DEFAULT -> let { c1# :: GHC.Prim.Int# [LclId] - c1# = GHC.Prim.andI# 1# (GHC.Prim.<# wild 0#) } in - case GHC.Prim.quotInt# (GHC.Prim.-# 2# c1#) wild of wild1 + c1# = GHC.Prim.andI# 1# (GHC.Prim.<# wild1 0#) } in + case GHC.Prim.quotInt# (GHC.Prim.-# 2# c1#) wild1 of wild2 { __DEFAULT -> - GHC.Types.I# (GHC.Prim.-# wild1 c1#) + GHC.Types.I# (GHC.Prim.-# wild2 c1#) }; - -1# -> T18903.h2; 0# -> GHC.Real.divZeroError @Int } #); - 1# -> (# ww, T18903.h1 #) + 1# -> (# wild, T18903.h1 #) } } in - case ww of ds { + case ds of ds1 { __DEFAULT -> - case $wg ds of { (# ww1, ww2 #) -> - case ww2 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# ww1 y) } + case $wg ds1 of { (# ww, ww1 #) -> + case ww of { GHC.Types.I# x -> + case ww1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } + } }; 1# -> T18903.h1; - 2# -> case $wg 2# of { (# ww1, ww2 #) -> ww2 } + 2# -> case $wg 2# of { (# ww, ww1 #) -> ww1 } + } } - --- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0} -h [InlPrag=[2]] :: Int -> Int -[GblId, - Arity=1, - Str=<1P(SL)>, - 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= \ (w [Occ=Once1!] :: Int) -> - case w of { GHC.Types.I# ww [Occ=Once1] -> T18903.$wh ww }}] -h = \ (w :: Int) -> case w of { GHC.Types.I# ww -> T18903.$wh ww } diff --git a/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr b/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr index c1fa7f22e6..075a819db8 100644 --- a/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr +++ b/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== BottomFromInnerLambda.$trModule: -BottomFromInnerLambda.expensive: <1P(SL)> -BottomFromInnerLambda.f: <1P(SL)> +BottomFromInnerLambda.expensive: <1!P(SL)> +BottomFromInnerLambda.f: <1!P(SL)> @@ -15,7 +15,7 @@ BottomFromInnerLambda.f: ==================== Strictness signatures ==================== BottomFromInnerLambda.$trModule: -BottomFromInnerLambda.expensive: <1P(1L)> -BottomFromInnerLambda.f: <1P(1L)> +BottomFromInnerLambda.expensive: <1!P(1L)> +BottomFromInnerLambda.f: <1!P(1L)> diff --git a/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr b/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr index 4cbc565ee2..ea089c36be 100644 --- a/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr +++ b/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr @@ -9,7 +9,7 @@ DmdAnalGADTs.f: <1L> DmdAnalGADTs.f': <1L> DmdAnalGADTs.g: <1L> DmdAnalGADTs.hasCPR: -DmdAnalGADTs.hasStrSig: <1P(L)> +DmdAnalGADTs.hasStrSig: <1!L> @@ -37,6 +37,6 @@ DmdAnalGADTs.f: <1L> DmdAnalGADTs.f': <1L> DmdAnalGADTs.g: <1L> DmdAnalGADTs.hasCPR: -DmdAnalGADTs.hasStrSig: <1P(L)> +DmdAnalGADTs.hasStrSig: <1!L> diff --git a/testsuite/tests/stranal/sigs/HyperStrUse.stderr b/testsuite/tests/stranal/sigs/HyperStrUse.stderr index 09829ae4fa..3e791439a1 100644 --- a/testsuite/tests/stranal/sigs/HyperStrUse.stderr +++ b/testsuite/tests/stranal/sigs/HyperStrUse.stderr @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== HyperStrUse.$trModule: -HyperStrUse.f: <1P(1P(L),A)><1L> +HyperStrUse.f: <1!P(1!L,A)><1L> @@ -13,6 +13,6 @@ HyperStrUse.f: 1 ==================== Strictness signatures ==================== HyperStrUse.$trModule: -HyperStrUse.f: <1P(1P(L),A)><1L> +HyperStrUse.f: <1!P(1!L,A)><1L> diff --git a/testsuite/tests/stranal/sigs/NewtypeArity.stderr b/testsuite/tests/stranal/sigs/NewtypeArity.stderr index 66a810f5a5..8e6de7eb90 100644 --- a/testsuite/tests/stranal/sigs/NewtypeArity.stderr +++ b/testsuite/tests/stranal/sigs/NewtypeArity.stderr @@ -3,8 +3,8 @@ Test.$tc'MkT: Test.$tcT: Test.$trModule: -Test.t: <1P(L)><1P(L)> -Test.t2: <1P(L)><1P(L)> +Test.t: <1!L><1!L> +Test.t2: <1!L><1!L> @@ -21,7 +21,7 @@ Test.t2: 1 Test.$tc'MkT: Test.$tcT: Test.$trModule: -Test.t: <1P(L)><1P(L)> -Test.t2: <1P(L)><1P(L)> +Test.t: <1!L><1!L> +Test.t2: <1!L><1!L> diff --git a/testsuite/tests/stranal/sigs/T12370.stderr b/testsuite/tests/stranal/sigs/T12370.stderr index ac5eb53888..a8bbcd0e4c 100644 --- a/testsuite/tests/stranal/sigs/T12370.stderr +++ b/testsuite/tests/stranal/sigs/T12370.stderr @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== T12370.$trModule: -T12370.bar: <1P(L)><1P(L)> -T12370.foo: <1P(1P(L),1P(L))> +T12370.bar: <1!L><1!L> +T12370.foo: <1!P(1!L,1!L)> @@ -15,7 +15,7 @@ T12370.foo: 1 ==================== Strictness signatures ==================== T12370.$trModule: -T12370.bar: <1P(L)><1P(L)> -T12370.foo: <1P(1P(L),1P(L))> +T12370.bar: <1!L><1!L> +T12370.foo: <1!P(1!L,1!L)> diff --git a/testsuite/tests/stranal/sigs/T13331.hs b/testsuite/tests/stranal/sigs/T13331.hs new file mode 100644 index 0000000000..5f4a4a1631 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T13331.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE MagicHash, BangPatterns #-} + +module T13331 (naiveInsertInt) where + +data Map k a = Bin !Int !k a (Map k a) (Map k a) + | Tip + +singleton :: k -> a -> Map k a +singleton k a = Bin 1 k a Tip Tip + +balanceL :: k -> a -> Map k a -> Map k a -> Map k a +balanceL !_ _ !_ !_ = undefined +{-# NOINLINE balanceL #-} + +balanceR :: k -> a -> Map k a -> Map k a -> Map k a +balanceR !_ _ !_ !_ = undefined +{-# NOINLINE balanceR #-} + +-- | Should not unbox `kx`. +naiveInsertInt :: Int -> a -> Map Int a -> Map Int a +naiveInsertInt !kx x Tip = singleton kx x +naiveInsertInt !kx x t@(Bin sz ky y l r) = + case compare kx ky of + LT -> balanceL ky y l' r + where !l' = naiveInsertInt kx x l + GT -> balanceR ky y l r' + where !r' = naiveInsertInt kx x r + EQ -> Bin sz kx x l r + diff --git a/testsuite/tests/stranal/sigs/T13331.stderr b/testsuite/tests/stranal/sigs/T13331.stderr new file mode 100644 index 0000000000..78cccb7fe4 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T13331.stderr @@ -0,0 +1,27 @@ + +==================== Strictness signatures ==================== +T13331.$tc'Bin: +T13331.$tc'Tip: +T13331.$tcMap: +T13331.$trModule: +T13331.naiveInsertInt: <1L><L><1L> + + + +==================== Cpr signatures ==================== +T13331.$tc'Bin: +T13331.$tc'Tip: +T13331.$tcMap: +T13331.$trModule: +T13331.naiveInsertInt: + + + +==================== Strictness signatures ==================== +T13331.$tc'Bin: +T13331.$tc'Tip: +T13331.$tcMap: +T13331.$trModule: +T13331.naiveInsertInt: <1L><L><1L> + + diff --git a/testsuite/tests/stranal/sigs/T13380f.stderr b/testsuite/tests/stranal/sigs/T13380f.stderr index f4caa18a11..ad68f821d8 100644 --- a/testsuite/tests/stranal/sigs/T13380f.stderr +++ b/testsuite/tests/stranal/sigs/T13380f.stderr @@ -1,9 +1,9 @@ ==================== Strictness signatures ==================== T13380f.$trModule: -T13380f.f: <1P(L)><1P(L)><L> -T13380f.g: <1P(L)><MP(L)><L> -T13380f.h: <1P(L)><MP(L)><L> +T13380f.f: <1!L><1!L><L> +T13380f.g: <1!L><ML><L> +T13380f.h: <1!L><ML><L> T13380f.interruptibleCall: <L> T13380f.safeCall: <L> T13380f.unsafeCall: <L> @@ -23,9 +23,9 @@ T13380f.unsafeCall: 1(, 1) ==================== Strictness signatures ==================== T13380f.$trModule: -T13380f.f: <1P(L)><1P(L)><L> -T13380f.g: <1P(L)><MP(L)><L> -T13380f.h: <1P(L)><MP(L)><L> +T13380f.f: <1!L><1!L><L> +T13380f.g: <1!L><ML><L> +T13380f.h: <1!L><ML><L> T13380f.interruptibleCall: <L> T13380f.safeCall: <L> T13380f.unsafeCall: <L> diff --git a/testsuite/tests/stranal/sigs/T16197b.hs b/testsuite/tests/stranal/sigs/T16197b.hs new file mode 100644 index 0000000000..4ce440d3bf --- /dev/null +++ b/testsuite/tests/stranal/sigs/T16197b.hs @@ -0,0 +1,12 @@ +-- | The same as T16197, but a bit more distilled. +-- Important takeaway: The signature of `f` may not say "strict in the Bool +-- field of T", otherwise the Simplifier will drop the `seq` on the `Bool` at +-- call sites after unboxing the `T`. +module T16197b where + +data T = T !Bool +data Box a = Box a + +f :: T -> Box Bool +f (T b) = Box b +{-# NOINLINE f #-} -- I like NOINLINE better than artificial recursion, YMMV diff --git a/testsuite/tests/stranal/sigs/T16197b.stderr b/testsuite/tests/stranal/sigs/T16197b.stderr new file mode 100644 index 0000000000..96481ec378 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T16197b.stderr @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T16197b.$tc'Box: +T16197b.$tc'T: +T16197b.$tcBox: +T16197b.$tcT: +T16197b.$trModule: +T16197b.f: <1!L> + + + +==================== Cpr signatures ==================== +T16197b.$tc'Box: +T16197b.$tc'T: +T16197b.$tcBox: +T16197b.$tcT: +T16197b.$trModule: +T16197b.f: 1 + + + +==================== Strictness signatures ==================== +T16197b.$tc'Box: +T16197b.$tc'T: +T16197b.$tcBox: +T16197b.$tcT: +T16197b.$trModule: +T16197b.f: <1!L> + + diff --git a/testsuite/tests/stranal/sigs/T16859.hs b/testsuite/tests/stranal/sigs/T16859.hs new file mode 100644 index 0000000000..59af81785e --- /dev/null +++ b/testsuite/tests/stranal/sigs/T16859.hs @@ -0,0 +1,41 @@ +module T16859 where + +import GHC.Types.Name (OccName) +import GHC.Types.SrcLoc +import GHC.Types.Unique + +data NameSort = Internal | External + +data Name = Name { + n_sort :: NameSort, -- What sort of name it is + n_occ :: !OccName, -- Its occurrence name + n_uniq :: {-# UNPACK #-} !Unique, + n_loc :: !SrcSpan -- Definition site + } + +{-# NOINLINE mkInternalName #-} +mkInternalName :: Unique -> OccName -> SrcSpan -> Name +mkInternalName uniq occ loc = Name { n_uniq = uniq + , n_sort = Internal + , n_occ = occ + , n_loc = loc } + +-- | Should not unbox `x`. +foo :: Int -> Int -> (Int, Int) +foo x y = x `seq` (x, y) +{-# NOINLINE foo #-} + +-- | Should unbox `x`. +bar :: Int -> Int -> (Int, Int) +bar x y = x `seq` (y, y) +{-# NOINLINE bar #-} + +-- | Should not unbox `x`. +baz :: Int -> Int -> (Int -> Int) -> Int +baz x y f = x `seq` (f x + y) +{-# NOINLINE baz #-} + +-- | Should unbox `p`. +buz :: (Int, Int) -> (Int, Int) +buz p@(x,y) = (y,x) +{-# NOINLINE buz #-} diff --git a/testsuite/tests/stranal/sigs/T16859.stderr b/testsuite/tests/stranal/sigs/T16859.stderr new file mode 100644 index 0000000000..56c711f807 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T16859.stderr @@ -0,0 +1,57 @@ + +==================== Strictness signatures ==================== +T16859.$tc'External: +T16859.$tc'Internal: +T16859.$tc'Name: +T16859.$tcName: +T16859.$tcNameSort: +T16859.$trModule: +T16859.bar: <1!A><L> +T16859.baz: <1L><1!L><1C1(L)> +T16859.buz: <1!L> +T16859.foo: <1L><L> +T16859.mkInternalName: <1!L><1L><1L> +T16859.n_loc: <1!P(A,A,A,1L)> +T16859.n_occ: <1!P(A,1!L,A,A)> +T16859.n_sort: <1!P(1L,A,A,A)> +T16859.n_uniq: <1!P(A,A,L,A)> + + + +==================== Cpr signatures ==================== +T16859.$tc'External: +T16859.$tc'Internal: +T16859.$tc'Name: +T16859.$tcName: +T16859.$tcNameSort: +T16859.$trModule: +T16859.bar: 1 +T16859.baz: 1 +T16859.buz: 1 +T16859.foo: 1 +T16859.mkInternalName: 1(1, , ,) +T16859.n_loc: +T16859.n_occ: 1 +T16859.n_sort: +T16859.n_uniq: 1 + + + +==================== Strictness signatures ==================== +T16859.$tc'External: +T16859.$tc'Internal: +T16859.$tc'Name: +T16859.$tcName: +T16859.$tcNameSort: +T16859.$trModule: +T16859.bar: <1!A><L> +T16859.baz: <1L><1!L><1C1(L)> +T16859.buz: <1!L> +T16859.foo: <1L><L> +T16859.mkInternalName: <1!L><1L><1L> +T16859.n_loc: <1!P(A,A,A,1L)> +T16859.n_occ: <1!P(A,1!L,A,A)> +T16859.n_sort: <1!P(1L,A,A,A)> +T16859.n_uniq: <1!P(A,A,L,A)> + + diff --git a/testsuite/tests/stranal/sigs/T17932.stderr b/testsuite/tests/stranal/sigs/T17932.stderr index 0875f5844e..dadd60b491 100644 --- a/testsuite/tests/stranal/sigs/T17932.stderr +++ b/testsuite/tests/stranal/sigs/T17932.stderr @@ -5,7 +5,7 @@ T17932.$tc'X: T17932.$tcOptions: T17932.$tcX: T17932.$trModule: -T17932.flags: <1P(1L,1L)> +T17932.flags: <1!P(1L,1L)> @@ -25,6 +25,6 @@ T17932.$tc'X: T17932.$tcOptions: T17932.$tcX: T17932.$trModule: -T17932.flags: <1P(1L,1L)> +T17932.flags: <1!P(1L,1L)> diff --git a/testsuite/tests/stranal/sigs/T18907.hs b/testsuite/tests/stranal/sigs/T18907.hs new file mode 100644 index 0000000000..0a5c0fb50b --- /dev/null +++ b/testsuite/tests/stranal/sigs/T18907.hs @@ -0,0 +1,32 @@ +module T18907 (m, f, g, h) where + +import Control.Monad (forever) +import Control.Monad.Trans.State.Strict + +inc :: State Int () +inc = modify' (+1) + +m :: State Int () +m = forever inc + +data Huge = H Int Int Int Int Int + +-- | Should not unbox `x`. +f :: Huge -> Huge +f !x + | sum [0..24::Int] == 1 = x + | otherwise = H 0 0 0 0 0 +{-# NOINLINE f #-} + +-- | Should not unbox `x`. +g :: Huge -> Huge +g x@(H a b c d e) = a `seq` x +{-# NOINLINE g #-} + +seq' a b = seq a b +{-# NOINLINE seq' #-} + +-- | Should not unbox `y`. Unboxing `x` is OK. +h :: Int -> Int -> Int +h x y = (x+1) `seq'` y +{-# NOINLINE h #-} diff --git a/testsuite/tests/stranal/sigs/T18907.stderr b/testsuite/tests/stranal/sigs/T18907.stderr new file mode 100644 index 0000000000..2a1c84d3d5 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T18907.stderr @@ -0,0 +1,33 @@ + +==================== Strictness signatures ==================== +T18907.$tc'H: +T18907.$tcHuge: +T18907.$trModule: +T18907.f: <1!L> +T18907.g: <1P(SL,L,L,L,L)> +T18907.h: <1!A><1L> +T18907.m: <1!B>b + + + +==================== Cpr signatures ==================== +T18907.$tc'H: +T18907.$tcHuge: +T18907.$trModule: +T18907.f: 1 +T18907.g: +T18907.h: +T18907.m: b + + + +==================== Strictness signatures ==================== +T18907.$tc'H: +T18907.$tcHuge: +T18907.$trModule: +T18907.f: <1!L> +T18907.g: <1P(SL,L,L,L,L)> +T18907.h: <1!A><1L> +T18907.m: <1!B>b + + diff --git a/testsuite/tests/stranal/sigs/T18957.hs b/testsuite/tests/stranal/sigs/T18957.hs index 9781b7cd58..8f4550696d 100644 --- a/testsuite/tests/stranal/sigs/T18957.hs +++ b/testsuite/tests/stranal/sigs/T18957.hs @@ -1,11 +1,13 @@ {-# OPTIONS_GHC -O2 -fforce-recomp #-} {-# LANGUAGE BangPatterns #-} --- | This ticket is about demand `seq` puts its first argument under and --- how that affects call demands. +-- | This ticket is about the demand `seq` puts its first argument under and how +-- that affects call demands. module T18957 where -- | Should put its first argument under head demand +-- Note that seq' is like seq, but NOINLINE, so the calling code will not have +-- access to the case binder. That is the difference between 'h1' and 'h2'. seq' :: a -> b -> b seq' a b = seq a b {-# NOINLINE seq' #-} @@ -18,7 +20,6 @@ g f x = if x < 100 then f x else 200 -- | The first argument is evaluated multiple times, but called at most once -- every time it's evaluated h1 :: (Int -> Int) -> Int -> Int --- Note that seq' is like seq, but NOINLINE. See h2 below why h1 f x = f `seq'` if x < 100 then f x else 200 -- | Like h1, but using `seq` directly, which will rewrite the call site diff --git a/testsuite/tests/stranal/sigs/T18957.stderr b/testsuite/tests/stranal/sigs/T18957.stderr index 6795bf0dab..c1c09c6b4a 100644 --- a/testsuite/tests/stranal/sigs/T18957.stderr +++ b/testsuite/tests/stranal/sigs/T18957.stderr @@ -1,10 +1,10 @@ ==================== Strictness signatures ==================== T18957.$trModule: -T18957.g: <MCM(L)><1P(L)> -T18957.h1: <SCM(L)><1P(L)> -T18957.h2: <1CM(L)><1P(L)> -T18957.h3: <LCL(P(L))><1P(L)> +T18957.g: <MCM(L)><1!L> +T18957.h1: <SCM(L)><1!L> +T18957.h2: <1CM(L)><1!L> +T18957.h3: <L><1!L> T18957.seq': <1A><1L> @@ -21,10 +21,10 @@ T18957.seq': ==================== Strictness signatures ==================== T18957.$trModule: -T18957.g: <MCM(L)><1P(L)> -T18957.h1: <SCM(L)><1P(L)> -T18957.h2: <1CM(L)><1P(L)> -T18957.h3: <LCL(P(L))><1P(L)> +T18957.g: <MCM(L)><1!L> +T18957.h1: <SCM(L)><1!L> +T18957.h2: <1CM(L)><1!L> +T18957.h3: <L><1!L> T18957.seq': <1A><1L> diff --git a/testsuite/tests/stranal/sigs/T19407.hs b/testsuite/tests/stranal/sigs/T19407.hs new file mode 100644 index 0000000000..f404d48de0 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T19407.hs @@ -0,0 +1,21 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +-- | The gist here: `f` is strict in `t::T` and its field `h::Huge`, but mustn't unbox it. +-- Otherwise, `$wf` has to rebox it for the call to `$wg` (which is lazy in `t`) and that +-- also means reconstructing `h`, although most fields are absent anyway. +-- +-- Solution: `g` is lazy in `t` and we can't unbox it. Thus, its signature +-- shouldn't say `Unboxed` for `t`! +module T19407 where + +data Huge = Huge Bool () () () () () () () () () () () () () () () () () () () () () +data T = T { h :: Huge, n :: Int } + +f :: T -> Int -- like warnAboutOverflowedLit +f t = g (h t) t +{-# NOINLINE f #-} + +g :: Huge -> T -> Int -- like warnAboutOverflowedLiterals +g (Huge b _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) t = + if b then 0 else n t +{-# NOINLINE g #-} diff --git a/testsuite/tests/stranal/sigs/T19407.stderr b/testsuite/tests/stranal/sigs/T19407.stderr new file mode 100644 index 0000000000..c0cec03a4d --- /dev/null +++ b/testsuite/tests/stranal/sigs/T19407.stderr @@ -0,0 +1,39 @@ + +==================== Strictness signatures ==================== +T19407.$tc'Huge: +T19407.$tc'T: +T19407.$tcHuge: +T19407.$tcT: +T19407.$trModule: +T19407.f: <SP(1P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A),ML)> +T19407.g: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)><MP(A,ML)> +T19407.h: <1!P(1L,A)> +T19407.n: <1!P(A,1!L)> + + + +==================== Cpr signatures ==================== +T19407.$tc'Huge: +T19407.$tc'T: +T19407.$tcHuge: +T19407.$tcT: +T19407.$trModule: +T19407.f: +T19407.g: +T19407.h: +T19407.n: 1 + + + +==================== Strictness signatures ==================== +T19407.$tc'Huge: +T19407.$tc'T: +T19407.$tcHuge: +T19407.$tcT: +T19407.$trModule: +T19407.f: <1P(1P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A),ML)> +T19407.g: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)><MP(A,ML)> +T19407.h: <1!P(1L,A)> +T19407.n: <1!P(A,1!L)> + + diff --git a/testsuite/tests/stranal/sigs/T19871.hs b/testsuite/tests/stranal/sigs/T19871.hs new file mode 100644 index 0000000000..564a055df4 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T19871.hs @@ -0,0 +1,70 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +-- | From Note [Boxity Analysis] and related Notes +module T19871 where + +data Huge + = Huge + { f1 :: Bool + , f2 :: Bool + , f3 :: Bool + , f4 :: Bool + , f5 :: Bool + , f6 :: Bool + , f7 :: Bool + , f8 :: Bool + , f9 :: Bool + , f10 :: Bool + , f11 :: Bool + , f12 :: Bool } + +-- | Should not unbox Huge +ann :: Huge -> (Bool, Huge) +ann h@(Huge{f1=True}) = (False, h) +ann h = (True, h) +{-# NOINLINE ann #-} + +-- A few examples demonstrating the lubBoxity = unboxedWins tradeoff + +-- | Should unbox 'z'. +-- We won't with `lubBoxity = boxedWins`. +-- We will with `lubBoxity = unboxedWins`. +sumIO :: Int -> Int -> IO Int +sumIO 0 !z = return z +sumIO n !z = sumIO (n-1) (z+n) +{-# NOINLINE sumIO #-} + +-- | Should /not/ unbox 'h'. +-- We won't with `lubBoxity = boxedWins`. +-- We will with `lubBoxity = unboxedWins`. +update :: Huge -> (Bool, Huge) +update h@(Huge{f1=True}) = (False, h{f1=False}) +update h = (True, h) +{-# NOINLINE update #-} + +-- | Should /not/ unbox 'h'. +-- We won't with `lubBoxity = boxedWins`. +-- We will with `lubBoxity = unboxedWins`. +guarded :: (Huge -> Bool) -> Huge -> Bool +guarded g h | f1 h = True + | otherwise = g h +{-# NOINLINE guarded #-} + +-- | Should /not/ unbox 'h'. +-- We won't with `lubBoxity = boxedWins`. +-- We will with `lubBoxity = unboxedWins`. +-- +-- This example also demonstrates the usefulness of carrying a Boxity in Poly. +-- Most absent sub-demands here should be considered Boxed (and of course we +-- also need Unboxed absent Poly). See Note [Boxity in Poly]. +absent :: Huge -> Int +absent h = if f1 h || f2 h then g h else 2 + where + g :: a -> Int + g a = a `seq` f a True + {-# NOINLINE g #-} + f :: a -> Bool -> Int + f _ True = 1 + f a False = a `seq` 2 + {-# NOINLINE f #-} +{-# NOINLINE absent #-} diff --git a/testsuite/tests/stranal/sigs/T19871.stderr b/testsuite/tests/stranal/sigs/T19871.stderr new file mode 100644 index 0000000000..14619b5891 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T19871.stderr @@ -0,0 +1,72 @@ + +==================== Strictness signatures ==================== +T19871.$tc'Huge: +T19871.$tcHuge: +T19871.$trModule: +T19871.absent: <1!P(1L,ML,A,A,A,A,A,A,A,A,A,A)> +T19871.ann: <1P(SL,L,L,L,L,L,L,L,L,L,L,L)> +T19871.f1: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A)> +T19871.f10: <1!P(A,A,A,A,A,A,A,A,A,1L,A,A)> +T19871.f11: <1!P(A,A,A,A,A,A,A,A,A,A,1L,A)> +T19871.f12: <1!P(A,A,A,A,A,A,A,A,A,A,A,1L)> +T19871.f2: <1!P(A,1L,A,A,A,A,A,A,A,A,A,A)> +T19871.f3: <1!P(A,A,1L,A,A,A,A,A,A,A,A,A)> +T19871.f4: <1!P(A,A,A,1L,A,A,A,A,A,A,A,A)> +T19871.f5: <1!P(A,A,A,A,1L,A,A,A,A,A,A,A)> +T19871.f6: <1!P(A,A,A,A,A,1L,A,A,A,A,A,A)> +T19871.f7: <1!P(A,A,A,A,A,A,1L,A,A,A,A,A)> +T19871.f8: <1!P(A,A,A,A,A,A,A,1L,A,A,A,A)> +T19871.f9: <1!P(A,A,A,A,A,A,A,A,1L,A,A,A)> +T19871.guarded: <MCM(L)><1!P(SL,L,L,L,L,L,L,L,L,L,L,L)> +T19871.sumIO: <1!P(1L)><1!L><L> +T19871.update: <1!P(SL,L,L,L,L,L,L,L,L,L,L,L)> + + + +==================== Cpr signatures ==================== +T19871.$tc'Huge: +T19871.$tcHuge: +T19871.$trModule: +T19871.absent: 1 +T19871.ann: 1 +T19871.f1: +T19871.f10: +T19871.f11: +T19871.f12: +T19871.f2: +T19871.f3: +T19871.f4: +T19871.f5: +T19871.f6: +T19871.f7: +T19871.f8: +T19871.f9: +T19871.guarded: +T19871.sumIO: 1(, 1) +T19871.update: 1 + + + +==================== Strictness signatures ==================== +T19871.$tc'Huge: +T19871.$tcHuge: +T19871.$trModule: +T19871.absent: <1!P(1L,ML,A,A,A,A,A,A,A,A,A,A)> +T19871.ann: <1P(SL,L,L,L,L,L,L,L,L,L,L,L)> +T19871.f1: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A)> +T19871.f10: <1!P(A,A,A,A,A,A,A,A,A,1L,A,A)> +T19871.f11: <1!P(A,A,A,A,A,A,A,A,A,A,1L,A)> +T19871.f12: <1!P(A,A,A,A,A,A,A,A,A,A,A,1L)> +T19871.f2: <1!P(A,1L,A,A,A,A,A,A,A,A,A,A)> +T19871.f3: <1!P(A,A,1L,A,A,A,A,A,A,A,A,A)> +T19871.f4: <1!P(A,A,A,1L,A,A,A,A,A,A,A,A)> +T19871.f5: <1!P(A,A,A,A,1L,A,A,A,A,A,A,A)> +T19871.f6: <1!P(A,A,A,A,A,1L,A,A,A,A,A,A)> +T19871.f7: <1!P(A,A,A,A,A,A,1L,A,A,A,A,A)> +T19871.f8: <1!P(A,A,A,A,A,A,A,1L,A,A,A,A)> +T19871.f9: <1!P(A,A,A,A,A,A,A,A,1L,A,A,A)> +T19871.guarded: <MCM(L)><1!P(SL,L,L,L,L,L,L,L,L,L,L,L)> +T19871.sumIO: <1!P(1L)><1!L><L> +T19871.update: <1!P(SL,L,L,L,L,L,L,L,L,L,L,L)> + + diff --git a/testsuite/tests/stranal/sigs/T5075.stderr b/testsuite/tests/stranal/sigs/T5075.stderr index c9625db721..7652a16f0a 100644 --- a/testsuite/tests/stranal/sigs/T5075.stderr +++ b/testsuite/tests/stranal/sigs/T5075.stderr @@ -1,9 +1,9 @@ ==================== Strictness signatures ==================== T5075.$trModule: -T5075.f: <SP(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> -T5075.g: <1P(L)><SP(L)> -T5075.h: <SP(L)> +T5075.f: <S!P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> +T5075.g: <1!L><S!L> +T5075.h: <S!L> @@ -18,7 +18,7 @@ T5075.h: ==================== Strictness signatures ==================== T5075.$trModule: T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> -T5075.g: <1P(L)><SP(L)> -T5075.h: <1P(L)> +T5075.g: <1!L><S!L> +T5075.h: <1!L> diff --git a/testsuite/tests/stranal/sigs/T8598.stderr b/testsuite/tests/stranal/sigs/T8598.stderr index db7c97f807..e8813a0fc8 100644 --- a/testsuite/tests/stranal/sigs/T8598.stderr +++ b/testsuite/tests/stranal/sigs/T8598.stderr @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== T8598.$trModule: -T8598.fun: <1P(L)> +T8598.fun: <1!L> @@ -13,6 +13,6 @@ T8598.fun: 1 ==================== Strictness signatures ==================== T8598.$trModule: -T8598.fun: <1P(L)> +T8598.fun: <1!L> diff --git a/testsuite/tests/stranal/sigs/UnsatFun.stderr b/testsuite/tests/stranal/sigs/UnsatFun.stderr index b3ccac6f6e..a9c3ca340a 100644 --- a/testsuite/tests/stranal/sigs/UnsatFun.stderr +++ b/testsuite/tests/stranal/sigs/UnsatFun.stderr @@ -1,9 +1,9 @@ ==================== Strictness signatures ==================== UnsatFun.$trModule: -UnsatFun.f: <1P(S)><B>b -UnsatFun.g: <1P(S)>b -UnsatFun.g': <MP(L)> +UnsatFun.f: <1!S><B>b +UnsatFun.g: <1!S>b +UnsatFun.g': <ML> UnsatFun.g3: <A> UnsatFun.h: <1C1(L)> UnsatFun.h2: <1L><MCM(L)> @@ -25,9 +25,9 @@ UnsatFun.h3: 1 ==================== Strictness signatures ==================== UnsatFun.$trModule: -UnsatFun.f: <1P(S)><B>b -UnsatFun.g: <1P(S)>b -UnsatFun.g': <MP(L)> +UnsatFun.f: <1!S><B>b +UnsatFun.g: <1!S>b +UnsatFun.g': <ML> UnsatFun.g3: <A> UnsatFun.h: <1C1(L)> UnsatFun.h2: <1L><MCM(L)> diff --git a/testsuite/tests/stranal/sigs/all.T b/testsuite/tests/stranal/sigs/all.T index 5d562a6a8c..95065c2d23 100644 --- a/testsuite/tests/stranal/sigs/all.T +++ b/testsuite/tests/stranal/sigs/all.T @@ -23,3 +23,9 @@ test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) test('T18086', normal, compile, ['-package ghc']) test('T18957', normal, compile, ['']) +test('T16197b', normal, compile, ['']) +test('T19407', normal, compile, ['']) +test('T19871', normal, compile, ['']) +test('T16859', normal, compile, ['-package ghc']) +test('T18907', normal, compile, ['']) +test('T13331', normal, compile, ['']) |