diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-01-13 08:56:53 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-01-23 17:41:20 +0000 |
commit | 596dece7866006d699969f775fd97bd306aad85b (patch) | |
tree | 916401e099d6b5ad8f59ba4939e80d6ad93f0bad /testsuite/tests/stranal | |
parent | 729a5e452db530e8da8ca163fcd842faac6bd690 (diff) | |
download | haskell-596dece7866006d699969f775fd97bd306aad85b.tar.gz |
Record evaluated-ness on workers and wrappers
Summary:
This patch is a refinement of the original commit (which
was reverted):
commit 6b976eb89fe72827f226506d16d3721ba4e28bab
Date: Fri Jan 13 08:56:53 2017 +0000
Record evaluated-ness on workers and wrappers
In Trac #13027, comment:20, I noticed that wrappers created after
demand analysis weren't recording the evaluated-ness of strict
constructor arguments. In the ticket that led to a (debatable)
Lint error but in general the more we know about evaluated-ness
the better we can optimise.
This commit adds that info
* both in the worker (on args)
* and in the wrapper (on CPR result patterns).
See Note [Record evaluated-ness in worker/wrapper] in WwLib
On the way I defined Id.setCaseBndrEvald, and used it to shorten
the code in a few other places
Then I added test T13077a to test the CPR aspect of this patch,
but I found that Lint failed!
Reason: simpleOptExpr was discarding evaluated-ness info on
lambda binders because zapFragileIdInfo was discarding an
Unfolding of (OtherCon _). But actually that's a robust
unfolding; there is no need to discard it. To fix this:
* zapFragileIdInfo only zaps fragile unfoldings
* Replace isClosedUnfolding with isFragileUnfolding (the latter
is just the negation of the former, but the nomenclature is
more consistent). Better documentation too
Note [Fragile unfoldings]
* And Simplify.simplLamBndr can now look at isFragileUnfolding
to decide whether to use the longer route of simplUnfolding.
For some reason perf/compiler/T9233 improves in compile-time
allocation by 10%. Hooray
Nofib: essentially no change:
--------------------------------------------------------------------------------
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
cacheprof +0.0% -0.3% +0.9% +0.4% +0.0%
--------------------------------------------------------------------------------
Min +0.0% -0.3% -2.4% -2.4% +0.0%
Max +0.0% +0.0% +9.8% +11.4% +2.4%
Geometric Mean +0.0% -0.0% +1.1% +1.0% +0.0%
Diffstat (limited to 'testsuite/tests/stranal')
-rw-r--r-- | testsuite/tests/stranal/should_compile/T13077.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/stranal/should_compile/T13077a.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/stranal/should_compile/all.T | 3 |
3 files changed, 38 insertions, 1 deletions
diff --git a/testsuite/tests/stranal/should_compile/T13077.hs b/testsuite/tests/stranal/should_compile/T13077.hs new file mode 100644 index 0000000000..193d39cb72 --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T13077.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module T13077 where +import GHC.Exts + +data X = A | B | C + +data T = MkT !X Int# Int# + +f (MkT x 0# _) = True +f (MkT x n _) = let v = case x of + A -> 1# + B -> 2# + C -> n + in f (MkT x v v) + -- Tests evaluatedness for worker args diff --git a/testsuite/tests/stranal/should_compile/T13077a.hs b/testsuite/tests/stranal/should_compile/T13077a.hs new file mode 100644 index 0000000000..aeaee11875 --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T13077a.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE MagicHash #-} +module T13077a where + +import GHC.Exts + +data X = A | B | C + +data T = MkT !X Int# Int# + +g :: Int -> T +g 0 = MkT A 1# 2# +g n = g (n-1) + +boo :: Int -> T +boo k = case g k of + MkT x n _ -> let v = case x of + A -> 1# + B -> 2# + C -> n + in MkT x v v + -- Tests evaluated-ness for CPR diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T index 5bbbfd5e55..d8fc7575cd 100644 --- a/testsuite/tests/stranal/should_compile/all.T +++ b/testsuite/tests/stranal/should_compile/all.T @@ -52,4 +52,5 @@ test('T11770', [ checkCoreString('OneShot') ], compile, ['-ddump-simpl']) test('T13031', normal, run_command, ['$MAKE -s --no-print-directory T13031']) - +test('T13077', normal, compile, ['']) +test('T13077a', normal, compile, ['']) |