diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-07-28 15:23:36 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-08-02 04:15:41 -0400 |
commit | 3968cd0c9282ea88b3952133f1c0ceb29bb23e03 (patch) | |
tree | 1476874987efba0915fc37e340dcc1cc32652be7 /testsuite | |
parent | 7bad93a286694c1cc63f781ac0c20e6319c1ae89 (diff) | |
download | haskell-3968cd0c9282ea88b3952133f1c0ceb29bb23e03.tar.gz |
Constant-fold unpackAppendCString (fix #20174)
Minor renaming: since 1ed0409010afeaa318676e351b833aea659bf93a rules get
an InScopeEnv arg (containing an IdUnfoldingFun) instead of an
IdUnfoldingFun directly, hence I've renamed the parameter from "id_unf"
to "env" for clarity.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T20174.hs | 18 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T20174.stderr | 19 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/all.T | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T20174.hs b/testsuite/tests/simplCore/should_compile/T20174.hs new file mode 100644 index 0000000000..d89a9645d8 --- /dev/null +++ b/testsuite/tests/simplCore/should_compile/T20174.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -ddump-simpl -dsuppress-all -dno-typeable-binds -O2 #-} + +module Test (foobar, foobar2, foobar3) where + +import GHC.Exts + +bar :: String +bar = unpackCString# "bar"# + +foobar :: String +foobar = unpackAppendCString# "foo"# bar + +foobar2 :: String +foobar2 = unpackAppendCString# "foo"# (unpackCString# "bar"#) + +foobar3 :: String +foobar3 = unpackAppendCString# "foo"# (unpackAppendCString# "bar"# []) diff --git a/testsuite/tests/simplCore/should_compile/T20174.stderr b/testsuite/tests/simplCore/should_compile/T20174.stderr new file mode 100644 index 0000000000..17141396a3 --- /dev/null +++ b/testsuite/tests/simplCore/should_compile/T20174.stderr @@ -0,0 +1,19 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 9, types: 4, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foobar1 = "foobar"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +foobar = unpackCString# foobar1 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foobar2 = foobar + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foobar3 = foobar + + + diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T index 616a469746..dbec3b3066 100644 --- a/testsuite/tests/simplCore/should_compile/all.T +++ b/testsuite/tests/simplCore/should_compile/all.T @@ -369,3 +369,4 @@ test('T19794', normal, compile, ['-O']) test('T19890', [ grep_errmsg(r'= T19890.foo1') ], compile, ['-O -ddump-simpl']) test('T20125', [ grep_errmsg(r'= T20125.MkT') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T20143', [ grep_errmsg(r'unsafeEqualityProof') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('T20174', normal, compile, ['']) |