summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-03-08 10:26:47 +0000
committerDavid Feuer <David.Feuer@gmail.com>2017-04-28 18:08:33 -0400
commit193664d42dbceadaa1e4689dfa17ff1cf5a405a0 (patch)
tree9288e57ab81dcbf9f633cae13d9920cf38a11754 /testsuite
parent1cae73aa7a1bf934e3dcae943d0d1686e8b12c26 (diff)
downloadhaskell-193664d42dbceadaa1e4689dfa17ff1cf5a405a0.tar.gz
Re-engineer caseRules to add tagToEnum/dataToTag
See Note [Scrutinee Constant Folding] in SimplUtils * Add cases for tagToEnum and dataToTag. This is the main new bit. It allows the simplifier to remove the pervasive uses of case tagToEnum (a > b) of False -> e1 True -> e2 and replace it by the simpler case a > b of DEFAULT -> e1 1# -> e2 See Note [caseRules for tagToEnum] and Note [caseRules for dataToTag] in PrelRules. * This required some changes to the API of caseRules, and hence to code in SimplUtils. See Note [Scrutinee Constant Folding] in SimplUtils. * Avoid duplication of work in the (unusual) case of case BIG + 3# of b DEFAULT -> e1 6# -> e2 Previously we got case BIG of DEFAULT -> let b = BIG + 3# in e1 3# -> let b = 6# in e2 Now we get case BIG of b# DEFAULT -> let b = b' + 3# in e1 3# -> let b = 6# in e2 * Avoid duplicated code in caseRules A knock-on refactoring: * Move Note [Word/Int underflow/overflow] to Literal, as documentation to accompany mkMachIntWrap etc; and get rid of PrelRuls.intResult' in favour of mkMachIntWrap
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/simplCore/should_compile/T3772.stdout10
-rw-r--r--testsuite/tests/simplCore/should_compile/T4930.stderr30
-rw-r--r--testsuite/tests/simplCore/should_compile/spec-inline.stderr152
3 files changed, 96 insertions, 96 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T3772.stdout b/testsuite/tests/simplCore/should_compile/T3772.stdout
index 44aee7b69e..a4ab97da38 100644
--- a/testsuite/tests/simplCore/should_compile/T3772.stdout
+++ b/testsuite/tests/simplCore/should_compile/T3772.stdout
@@ -1,7 +1,7 @@
==================== Tidy Core ====================
Result size of Tidy Core
- = {terms: 44, types: 19, coercions: 0, joins: 0/0}
+ = {terms: 43, types: 18, coercions: 0, joins: 0/0}
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
T3772.$trModule4 :: GHC.Prim.Addr#
@@ -59,14 +59,14 @@ $wxs
}
end Rec }
--- RHS size: {terms: 11, types: 3, coercions: 0, joins: 0/0}
+-- RHS size: {terms: 10, types: 2, coercions: 0, joins: 0/0}
T3772.$wfoo [InlPrag=NOINLINE] :: GHC.Prim.Int# -> ()
[GblId, Arity=1, Caf=NoCafRefs, Str=<S,U>]
T3772.$wfoo
= \ (ww :: GHC.Prim.Int#) ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<# 0# ww) of {
- False -> GHC.Tuple.();
- True -> $wxs ww
+ case GHC.Prim.<# 0# ww of {
+ __DEFAULT -> GHC.Tuple.();
+ 1# -> $wxs ww
}
-- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0}
diff --git a/testsuite/tests/simplCore/should_compile/T4930.stderr b/testsuite/tests/simplCore/should_compile/T4930.stderr
index 9db97a5e1f..4d569485b3 100644
--- a/testsuite/tests/simplCore/should_compile/T4930.stderr
+++ b/testsuite/tests/simplCore/should_compile/T4930.stderr
@@ -1,7 +1,7 @@
==================== Tidy Core ====================
Result size of Tidy Core
- = {terms: 44, types: 17, coercions: 0, joins: 0/0}
+ = {terms: 43, types: 16, coercions: 0, joins: 0/0}
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
T4930.$trModule4 :: GHC.Prim.Addr#
@@ -44,20 +44,20 @@ T4930.$trModule :: GHC.Types.Module
Str=m,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
-T4930.$trModule =
- GHC.Types.Module T4930.$trModule3 T4930.$trModule1
+T4930.$trModule
+ = GHC.Types.Module T4930.$trModule3 T4930.$trModule1
Rec {
--- RHS size: {terms: 18, types: 4, coercions: 0, joins: 0/0}
+-- RHS size: {terms: 17, types: 3, coercions: 0, joins: 0/0}
T4930.$wfoo [InlPrag=[0], Occ=LoopBreaker]
:: GHC.Prim.Int# -> GHC.Prim.Int#
[GblId, Arity=1, Caf=NoCafRefs, Str=<S,U>]
-T4930.$wfoo =
- \ (ww :: GHC.Prim.Int#) ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<# ww 5#) of {
- False -> GHC.Prim.+# ww 5#;
- True -> case T4930.$wfoo ww of { __DEFAULT -> GHC.Prim.+# ww 5# }
- }
+T4930.$wfoo
+ = \ (ww :: GHC.Prim.Int#) ->
+ case GHC.Prim.<# ww 5# of {
+ __DEFAULT -> GHC.Prim.+# ww 5#;
+ 1# -> case T4930.$wfoo ww of { __DEFAULT -> GHC.Prim.+# ww 5# }
+ }
end Rec }
-- RHS size: {terms: 10, types: 4, coercions: 0, joins: 0/0}
@@ -73,11 +73,11 @@ foo [InlPrag=INLINE[0]] :: Int -> Int
case w of { GHC.Types.I# ww1 [Occ=Once] ->
case T4930.$wfoo ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 }
}}]
-foo =
- \ (w :: Int) ->
- case w of { GHC.Types.I# ww1 ->
- case T4930.$wfoo ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 }
- }
+foo
+ = \ (w :: Int) ->
+ case w of { GHC.Types.I# ww1 ->
+ case T4930.$wfoo ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 }
+ }
diff --git a/testsuite/tests/simplCore/should_compile/spec-inline.stderr b/testsuite/tests/simplCore/should_compile/spec-inline.stderr
index dda28c8926..53b315dc9c 100644
--- a/testsuite/tests/simplCore/should_compile/spec-inline.stderr
+++ b/testsuite/tests/simplCore/should_compile/spec-inline.stderr
@@ -1,7 +1,7 @@
==================== Tidy Core ====================
Result size of Tidy Core
- = {terms: 178, types: 68, coercions: 0, joins: 0/2}
+ = {terms: 172, types: 62, coercions: 0, joins: 0/2}
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
Roman.$trModule4 :: GHC.Prim.Addr#
@@ -44,8 +44,8 @@ Roman.$trModule :: GHC.Types.Module
Str=m,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
-Roman.$trModule =
- GHC.Types.Module Roman.$trModule3 Roman.$trModule1
+Roman.$trModule
+ = GHC.Types.Module Roman.$trModule3 Roman.$trModule1
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
lvl :: GHC.Prim.Addr#
@@ -55,83 +55,83 @@ lvl = "spec-inline.hs:(19,5)-(29,25)|function go"#
-- RHS size: {terms: 2, types: 2, coercions: 0, joins: 0/0}
Roman.foo3 :: Int
[GblId, Str=x]
-Roman.foo3 =
- Control.Exception.Base.patError @ 'GHC.Types.LiftedRep @ Int lvl
+Roman.foo3
+ = Control.Exception.Base.patError @ 'GHC.Types.LiftedRep @ Int lvl
Rec {
--- RHS size: {terms: 55, types: 9, coercions: 0, joins: 0/1}
+-- RHS size: {terms: 52, types: 6, coercions: 0, joins: 0/1}
Roman.foo_$s$wgo [Occ=LoopBreaker]
:: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#
[GblId, Arity=2, Caf=NoCafRefs, Str=<S,U><S,U>]
-Roman.foo_$s$wgo =
- \ (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#) ->
- let {
- m :: GHC.Prim.Int#
- [LclId]
- m =
- GHC.Prim.+#
- (GHC.Prim.+#
- (GHC.Prim.+#
- (GHC.Prim.+# (GHC.Prim.+# (GHC.Prim.+# sc sc) sc) sc) sc)
- sc)
- sc } in
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<=# sc1 0#) of {
- False ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<# sc1 100#) of {
- False ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<# sc1 500#) of {
- False -> Roman.foo_$s$wgo (GHC.Prim.+# m m) (GHC.Prim.-# sc1 1#);
- True -> Roman.foo_$s$wgo m (GHC.Prim.-# sc1 3#)
- };
- True -> Roman.foo_$s$wgo sc (GHC.Prim.-# sc1 2#)
- };
- True -> 0#
- }
+Roman.foo_$s$wgo
+ = \ (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#) ->
+ let {
+ m :: GHC.Prim.Int#
+ [LclId]
+ m = GHC.Prim.+#
+ (GHC.Prim.+#
+ (GHC.Prim.+#
+ (GHC.Prim.+# (GHC.Prim.+# (GHC.Prim.+# sc sc) sc) sc) sc)
+ sc)
+ sc } in
+ case GHC.Prim.<=# sc1 0# of {
+ __DEFAULT ->
+ case GHC.Prim.<# sc1 100# of {
+ __DEFAULT ->
+ case GHC.Prim.<# sc1 500# of {
+ __DEFAULT ->
+ Roman.foo_$s$wgo (GHC.Prim.+# m m) (GHC.Prim.-# sc1 1#);
+ 1# -> Roman.foo_$s$wgo m (GHC.Prim.-# sc1 3#)
+ };
+ 1# -> Roman.foo_$s$wgo sc (GHC.Prim.-# sc1 2#)
+ };
+ 1# -> 0#
+ }
end Rec }
--- RHS size: {terms: 74, types: 22, coercions: 0, joins: 0/1}
+-- RHS size: {terms: 71, types: 19, coercions: 0, joins: 0/1}
Roman.$wgo [InlPrag=[0]] :: Maybe Int -> Maybe Int -> GHC.Prim.Int#
[GblId,
Arity=2,
Str=<S,1*U><S,1*U>,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
- WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 30] 256 0}]
-Roman.$wgo =
- \ (w :: Maybe Int) (w1 :: Maybe Int) ->
- case w1 of {
- Nothing -> case Roman.foo3 of wild1 { };
- Just x ->
- case x of { GHC.Types.I# ipv ->
- let {
- m :: GHC.Prim.Int#
- [LclId]
- m =
- GHC.Prim.+#
- (GHC.Prim.+#
- (GHC.Prim.+#
- (GHC.Prim.+# (GHC.Prim.+# (GHC.Prim.+# ipv ipv) ipv) ipv) ipv)
- ipv)
- ipv } in
- case w of {
- Nothing -> Roman.foo_$s$wgo m 10#;
- Just n ->
- case n of { GHC.Types.I# x2 ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<=# x2 0#) of {
- False ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<# x2 100#) of {
- False ->
- case GHC.Prim.tagToEnum# @ Bool (GHC.Prim.<# x2 500#) of {
- False -> Roman.foo_$s$wgo (GHC.Prim.+# m m) (GHC.Prim.-# x2 1#);
- True -> Roman.foo_$s$wgo m (GHC.Prim.-# x2 3#)
- };
- True -> Roman.foo_$s$wgo ipv (GHC.Prim.-# x2 2#)
- };
- True -> 0#
- }
- }
- }
- }
- }
+ WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 30] 253 0}]
+Roman.$wgo
+ = \ (w :: Maybe Int) (w1 :: Maybe Int) ->
+ case w1 of {
+ Nothing -> case Roman.foo3 of wild1 { };
+ Just x ->
+ case x of { GHC.Types.I# ipv ->
+ let {
+ m :: GHC.Prim.Int#
+ [LclId]
+ m = GHC.Prim.+#
+ (GHC.Prim.+#
+ (GHC.Prim.+#
+ (GHC.Prim.+# (GHC.Prim.+# (GHC.Prim.+# ipv ipv) ipv) ipv) ipv)
+ ipv)
+ ipv } in
+ case w of {
+ Nothing -> Roman.foo_$s$wgo m 10#;
+ Just n ->
+ case n of { GHC.Types.I# x2 ->
+ case GHC.Prim.<=# x2 0# of {
+ __DEFAULT ->
+ case GHC.Prim.<# x2 100# of {
+ __DEFAULT ->
+ case GHC.Prim.<# x2 500# of {
+ __DEFAULT ->
+ Roman.foo_$s$wgo (GHC.Prim.+# m m) (GHC.Prim.-# x2 1#);
+ 1# -> Roman.foo_$s$wgo m (GHC.Prim.-# x2 3#)
+ };
+ 1# -> Roman.foo_$s$wgo ipv (GHC.Prim.-# x2 2#)
+ };
+ 1# -> 0#
+ }
+ }
+ }
+ }
+ }
-- RHS size: {terms: 9, types: 5, coercions: 0, joins: 0/0}
Roman.foo_go [InlPrag=INLINE[0]] :: Maybe Int -> Maybe Int -> Int
@@ -143,9 +143,9 @@ Roman.foo_go [InlPrag=INLINE[0]] :: Maybe Int -> Maybe Int -> Int
Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False)
Tmpl= \ (w [Occ=Once] :: Maybe Int) (w1 [Occ=Once] :: Maybe Int) ->
case Roman.$wgo w w1 of ww { __DEFAULT -> GHC.Types.I# ww }}]
-Roman.foo_go =
- \ (w :: Maybe Int) (w1 :: Maybe Int) ->
- case Roman.$wgo w w1 of ww { __DEFAULT -> GHC.Types.I# ww }
+Roman.foo_go
+ = \ (w :: Maybe Int) (w1 :: Maybe Int) ->
+ case Roman.$wgo w w1 of ww { __DEFAULT -> GHC.Types.I# ww }
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
Roman.foo2 :: Int
@@ -178,11 +178,11 @@ foo :: Int -> Int
case n of n1 { GHC.Types.I# _ [Occ=Dead] ->
Roman.foo_go (GHC.Base.Just @ Int n1) Roman.foo1
}}]
-foo =
- \ (n :: Int) ->
- case n of { GHC.Types.I# ipv ->
- case Roman.foo_$s$wgo 6# ipv of ww { __DEFAULT -> GHC.Types.I# ww }
- }
+foo
+ = \ (n :: Int) ->
+ case n of { GHC.Types.I# ipv ->
+ case Roman.foo_$s$wgo 6# ipv of ww { __DEFAULT -> GHC.Types.I# ww }
+ }
------ Local rules for imported ids --------