diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-04-16 23:47:36 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2021-04-17 22:56:32 +0100 |
commit | 7bd12940fd2aebd4bf07cb3050ed1539fb948ce9 (patch) | |
tree | f81f135f2c808b49ef776711898ddea2dc30dbe2 /testsuite | |
parent | 0a8c14bd5a5438b1d042ad279b8ffff1bc867e7e (diff) | |
download | haskell-7bd12940fd2aebd4bf07cb3050ed1539fb948ce9.tar.gz |
Improve CSE in STG-land
This patch fixes #19717, a long-standing bug in CSE for STG, which
led to a stupid loss of CSE in some situations.
It's explained in Note [Trivial case scrutinee], which I have
substantially extended.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/simplStg/should_compile/T19717.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/simplStg/should_compile/T19717.stderr | 19 | ||||
-rw-r--r-- | testsuite/tests/simplStg/should_compile/all.T | 1 |
3 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/simplStg/should_compile/T19717.hs b/testsuite/tests/simplStg/should_compile/T19717.hs new file mode 100644 index 0000000000..2b485b6464 --- /dev/null +++ b/testsuite/tests/simplStg/should_compile/T19717.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +module Foo where + + +f x = x `seq` [Just x, Just x] diff --git a/testsuite/tests/simplStg/should_compile/T19717.stderr b/testsuite/tests/simplStg/should_compile/T19717.stderr new file mode 100644 index 0000000000..9dd1e085f8 --- /dev/null +++ b/testsuite/tests/simplStg/should_compile/T19717.stderr @@ -0,0 +1,19 @@ + +==================== Final STG: ==================== +Foo.f :: forall {a}. a -> [GHC.Maybe.Maybe a] +[GblId, Arity=1, Str=<1L>, Cpr=2, Unf=OtherCon []] = + {} \r [x] + case x of x1 { + __DEFAULT -> + let { + sat [Occ=Once1] :: GHC.Maybe.Maybe a + [LclId] = + CCCS GHC.Maybe.Just! [x1]; } in + let { + sat [Occ=Once1] :: [GHC.Maybe.Maybe a] + [LclId] = + CCCS :! [sat GHC.Types.[]]; + } in : [sat sat]; + }; + + diff --git a/testsuite/tests/simplStg/should_compile/all.T b/testsuite/tests/simplStg/should_compile/all.T index bb2e25ed4b..8cc4c49922 100644 --- a/testsuite/tests/simplStg/should_compile/all.T +++ b/testsuite/tests/simplStg/should_compile/all.T @@ -10,3 +10,4 @@ def f( name, opts ): setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) +test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) |