summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-05-21 16:51:50 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-27 14:57:39 -0400
commiteee498bfce3cce03ba1017b65d559c79d5c2eb60 (patch)
treed84aca47da56c7d90469412e090025527198bfc2 /testsuite/tests/stranal
parentd7758da490db3cc662dbebdac4397b4b2c38d0f0 (diff)
downloadhaskell-eee498bfce3cce03ba1017b65d559c79d5c2eb60.tar.gz
WorkWrap: Remove mkWWargs (#19874)
`mkWWargs`'s job was pushing casts inwards and doing eta expansion to match the arity with the number of argument demands we w/w for. Nowadays, we use the Simplifier to eta expand to arity. In fact, in recent years we have even seen the eta expansion done by w/w as harmful, see Note [Don't eta expand in w/w]. If a function hasn't enough manifest lambdas, don't w/w it! What purpose does `mkWWargs` serve in this world? Not a great one, it turns out! I could remove it by pulling some important bits, notably Note [Freshen WW arguments] and Note [Join points and beta-redexes]. Result: We reuse the freshened binder names of the wrapper in the worker where possible (see testuite changes), much nicer! In order to avoid scoping errors due to lambda-bound unfoldings in worker arguments, we zap those unfoldings now. In doing so, we fix #19766. Fixes #19874.
Diffstat (limited to 'testsuite/tests/stranal')
-rw-r--r--testsuite/tests/stranal/should_compile/T16029.stdout8
-rw-r--r--testsuite/tests/stranal/should_compile/T19766.hs19
-rw-r--r--testsuite/tests/stranal/should_compile/all.T1
3 files changed, 24 insertions, 4 deletions
diff --git a/testsuite/tests/stranal/should_compile/T16029.stdout b/testsuite/tests/stranal/should_compile/T16029.stdout
index 2d1f2106f3..76bf2617fb 100644
--- a/testsuite/tests/stranal/should_compile/T16029.stdout
+++ b/testsuite/tests/stranal/should_compile/T16029.stdout
@@ -4,8 +4,8 @@
:: GHC.Prim.Int# -> GHC.Prim.Int#
= \ (ww :: GHC.Prim.Int#) ->
g2 [InlPrag=[2]] :: T -> Int -> Int
- Tmpl= \ (w [Occ=Once1!] :: T) (w1 [Occ=Once1!] :: Int) ->
- = \ (w :: T) (w1 :: Int) ->
+ Tmpl= \ (ds [Occ=Once1!] :: T) (ds1 [Occ=Once1!] :: Int) ->
+ = \ (ds :: T) (ds1 :: Int) ->
g1 [InlPrag=[2]] :: S -> Int -> Int
- Tmpl= \ (w [Occ=Once1!] :: S) (w1 [Occ=Once1!] :: Int) ->
- = \ (w :: S) (w1 :: Int) ->
+ Tmpl= \ (ds [Occ=Once1!] :: S) (ds1 [Occ=Once1!] :: Int) ->
+ = \ (ds :: S) (ds1 :: Int) ->
diff --git a/testsuite/tests/stranal/should_compile/T19766.hs b/testsuite/tests/stranal/should_compile/T19766.hs
new file mode 100644
index 0000000000..1062c57cc1
--- /dev/null
+++ b/testsuite/tests/stranal/should_compile/T19766.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -O #-}
+
+module T19766 where
+
+data T a b = T !a !b
+
+data HasT = A (T Int Int) | B (T Int Int)
+
+getT :: HasT -> T Int Int
+getT (A t) = t
+getT (B t) = t
+
+f :: HasT -> [Int]
+f ht = case getT ht of t@(T _ _) -> reverse $ reverse $ reverse $ reverse $ reverse $ reverse $ lookupGRE t 15 [1,2,3,4]
+{-# NOINLINE f #-}
+
+lookupGRE :: T Int a -> Int -> [Int] -> [Int]
+lookupGRE ~(T n _) !k xs = [ x | x <- xs, x+k == n ]
+{-# NOINLINE lookupGRE #-}
diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T
index f5ebbf289a..9a210ea165 100644
--- a/testsuite/tests/stranal/should_compile/all.T
+++ b/testsuite/tests/stranal/should_compile/all.T
@@ -66,6 +66,7 @@ test('T18894b', [ grep_errmsg(r'Arity=2') ], compile, ['-ddump-stranal -dsuppre
test('T18982', [ grep_errmsg(r'\$w. .*Int#$') ], compile, ['-dppr-cols=1000 -ddump-simpl -dsuppress-idinfo -dsuppress-uniques'])
test('T19180', normal, compile, [''])
+test('T19766', [ grep_errmsg(r'absentError') ], compile, ['-ddump-worker-wrapper'])
test('T19849', normal, compile, [''])
test('T19882a', normal, compile, [''])
test('T19882b', normal, compile, [''])