| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
See https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker
This is based on work by Iavor Diatchki and Eric Seidel.
Test Plan: validate
Reviewers: simonpj, austin
Reviewed By: austin
Subscribers: gridaphobe, yav, thomie, carter
Differential Revision: https://phabricator.haskell.org/D489
Conflicts:
docs/users_guide/7.10.1-notes.xml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Turn CoreWriter into a newtype. A comment claimed something is forced
before returning, but it's actually not. Change comment to match
reality.
Reviewers: xich, simonpj, ezyang, austin
Reviewed By: ezyang, austin
Subscribers: thomie, carter
Differential Revision: https://phabricator.haskell.org/D453
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Generally clean up things relating to Applicative and Monad in `GHC.Base`
and `Control.Applicative` to make `Applicative` feel like a bit more of a
first-class citizen rather than just playing second fiddle to `Monad`. Use
`coerce` and GND to improve performance and clarity.
Change the default definition of `(*>)` to use `(<$)`, in case the
`Functor` instance optimizes that.
Moreover, some manually written instances are made into compiler-derived
instances.
Finally, this also adds a few AMP-related laws to the `Applicative` docstring.
NOTE: These changes result in a 13% decrease in allocation for T9020
Reviewed By: ekmett, hvr
Differential Revision: https://phabricator.haskell.org/D432
|
| |
|
| |
|
| |
|
|
|
|
|
| |
I forget all the details, but I spent some time trying to
understand the current setup, and tried to simplify it a bit
|
| |
|
| |
|
| |
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
|
|
|
| |
Closes #9561.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Don't export `getUs` and `getUniqueUs`. `UniqSM` has a `MonadUnique` instance:
instance MonadUnique UniqSM where
getUniqueSupplyM = getUs
getUniqueM = getUniqueUs
getUniquesM = getUniquesUs
Commandline-fu used:
git grep -l 'getUs\>' |
grep -v compiler/basicTypes/UniqSupply.lhs |
xargs sed -i 's/getUs/getUniqueSupplyM/g
git grep -l 'getUniqueUs\>' |
grep -v combiler/basicTypes/UniqSupply.lhs |
xargs sed -i 's/getUniqueUs/getUniqueM/g'
Follow up on b522d3a3f970a043397a0d6556ca555648e7a9c3
Reviewed By: austin, hvr
Differential Revision: https://phabricator.haskell.org/D220
|
| |
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes Trac #9583, a loop in the simplifier.
I thought this was going to be very complicated but it turned out to
be very simple! The occurrence analyser does something called
"glomming" if the application of imported RULES means that something
that didn't look recursive becomes recursive. See `Note [Glomming]`
in `OccurAnal`. Under these circumstances we group all the top-level
bindings into a single massive `Rec`.
But, crucially, I failed to repeat the occurrence analysis on this
glommed set of bindings. That means that we weren't establishing the
right loop breakers (indeed there were no loop breakers whatsoever),
and that led immediately to the loop. The only surprising this is that
it didn't happen before.
|
|
|
|
| |
Thanks to Gabor for pointing this out
|
|
|
|
| |
Fixes Trac #9529
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
This includes pretty much all the changes needed to make `Applicative`
a superclass of `Monad` finally. There's mostly reshuffling in the
interests of avoid orphans and boot files, but luckily we can resolve
all of them, pretty much. The only catch was that
Alternative/MonadPlus also had to go into Prelude to avoid this.
As a result, we must update the hsc2hs and haddock submodules.
Signed-off-by: Austin Seipp <austin@well-typed.com>
Test Plan: Build things, they might not explode horribly.
Reviewers: hvr, simonmar
Subscribers: simonmar
Differential Revision: https://phabricator.haskell.org/D13
|
| |
|
|
|
|
|
|
| |
Previously INLINE and INLINEABLE were treated identically, but it's
crucial that we don't choose a wrapper (INLINE) as a loop breaker,
when it is mutually recursive with an INLINEABLE worker.
|
|
|
|
|
|
| |
The "InlineRule" is gone now, so this is just making the comments line
up with the code. A function does change its name though:
updModeForInlineRules --> updModeForStableUnfoldings
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previusly we simply weren't doing CSE at all on things
whose unfolding were not always-active, for reasons explained
in Note [CSE for INLINE and NOINLINE]. But that was bad!
Making something INLNEABLE meant that its RHS was no longer
CSE'd, and that made some nofib programs worse.
And it's entirely unnecessary. I thoguht it through again,
wrote new comments (under the same Note), and things are
better again.
|
|
|
|
| |
Call sites are much easier to understand than before
|
|
|
|
| |
More modular, less code. No change in behaviour.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Doing so pushes bindings nearer their use site and hence makes
them more likely to be strict. These bindings might only show
up after the inlining from simplification. Example in fulsom,
Csg.calc, where an arg of timesDouble thereby becomes strict.
Very few programs are affected, but it's basically good news.
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
fft -0.2% +1.3% 0.06 0.06 -10.0%
fulsom -0.0% -2.6% -4.3% -4.7% -6.7%
simple +0.0% -0.8% 0.0% 0.0% 0.0%
--------------------------------------------------------------------------------
Min -0.5% -2.6% -4.5% -4.7% -10.0%
Max +0.1% +1.3% +3.3% +3.4% +2.6%
Geometric Mean -0.0% -0.0% -0.6% -0.6% -0.2%
The lossage in fft is the loss of detecting a common sub-expression,
and can be fixed by doing earlier CSE. But that is in any case a bit
of a fluke so I don't mind losing it in exchange for this more reliable
gain.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A class op applied to a dictionary doesn't do much work, so it's not
a great idea to float it out (except possibly to the top level.
See Note [Floating over-saturated applications] in SetLevels
I also renamed "floatOutPartialApplications" to "floatOutOverSatApps";
the former is deeply confusing, since there is no partial application
involved -- quite the reverse, it is *over* saturated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are two main refactorings here
1. Move the uf_arity field
out of CoreUnfolding
into UnfWhen
It's a lot tidier there. If I've got this right, no behaviour
should change.
2. Define specUnfolding and use it in DsBinds and Specialise
a) commons-up some shared code
b) makes sure that Specialise correctly specialises DFun
unfoldings (which it didn't before)
The two got put together because both ended up interacting in the
specialiser.
They cause zero difference to nofib.
|
| |
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
1. Respect condition (a) in Note [Binder swap]
2. Respect condition (b) in Note [Binder swap]
3. Return usage of any coercion variables in binder swap
Fixes T9440
Test Plan: See #9440
Reviewers: simonpj, austin
Reviewed By: simonpj, austin
Subscribers: simonpj, simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D156
GHC Trac Issues: #9440
|
|
|
|
|
|
| |
Mainly in Simplify.rebuildCase. The old code wasn't wrong, but I kept
mis-understanding it. This patch cuts splits out "pure seq" from "strict
let", which makes it much easier to grok.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In fixing Trac #9390 I discovered that I *still* didn't really understand
what the can_fail and has_side_effects properties of a PrimOp mean, precisely.
The big new things I learned are
* has_side_effects needs to be true only of *write* effects,
Reads (which are, strictly speaking, effects) don't matter here.
* has_side_effects must be true of primops that can throw a synchronous
Haskell exception (eg raiseIO#)
* can_fail is true only of primops that can cause an *unchecked* (not
Haskell) system exception, like divide by zero, or accessing memory
out of range through an array read or write.
I've documented all this now. The changes in this patch are only
in comments.
|
|
|
|
|
|
|
|
|
| |
It's not obvious why the simplifier generates code that correctly satisfies
the let/app invariant. This patch does some minor refactoring, but the main
point is to document pre-conditions to key functions, namely that the rhs
passed in satisfies the let/app invariant.
There shouldn't be any change in behaviour.
|
|
|
|
|
| |
We were inadvertently destroying the let/app invariant,
by floating into an unlifted function argument.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
reorganized, while following the convention, to
- place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
any `{-# OPTIONS_GHC #-}`-lines.
- Moreover, if the list of language extensions fit into a single
`{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
individual language extension. In both cases, try to keep the
enumeration alphabetically ordered.
(The latter layout is preferable as it's more diff-friendly)
While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See Note [Do not eta-expand PAPs] in SimplUtils. This has a tremendously
good effect on compile times for some simple benchmarks.
The test is now where it belongs, in perf/compiler/T9020 (instead of simpl015).
I did a nofib run and got essentially zero change except for cacheprof which
gets 4% more allocation. I investigated. Turns out that we have
instance PP Reg where
pp ppm ST_0 = "%st"
pp ppm ST_1 = "%st(1)"
pp ppm ST_2 = "%st(2)"
pp ppm ST_3 = "%st(3)"
pp ppm ST_4 = "%st(4)"
pp ppm ST_5 = "%st(5)"
pp ppm ST_6 = "%st(6)"
pp ppm ST_7 = "%st(7)"
pp ppm r = "%" ++ map toLower (show r)
That (map toLower (show r) does a lot of map/toLowers. But if we inline show
we get something like
pp ppm ST_0 = "%st"
pp ppm ST_1 = "%st(1)"
pp ppm ST_2 = "%st(2)"
pp ppm ST_3 = "%st(3)"
pp ppm ST_4 = "%st(4)"
pp ppm ST_5 = "%st(5)"
pp ppm ST_6 = "%st(6)"
pp ppm ST_7 = "%st(7)"
pp ppm EAX = map toLower (show EAX)
pp ppm EBX = map toLower (show EBX)
...etc...
and all those map/toLower calls can now be floated to top level.
This gives a 4% decrease in allocation. But it depends on inlining
a pretty big 'show' function.
With this new patch we get slightly better eta-expansion, which makes
a function look slightly bigger, which just stops it being inlined.
The previous behaviour was luck, so I'm not going to worry about
losing it.
I've added some notes to nofib/Simon-nofib-notes
|
|
|
|
|
|
|
|
|
|
| |
See Note [Demand analysis for trivial right-hand sides] in DmdAnal.
This allows a function with arity 2 to have a DmdSig with 3 args;
which in turn had a knock-on effect, which showed up in the test for
Trac #8963.
In fact it seems entirely reasonable, so this patch removes the
WARN and CoreLint checks that were complaining.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch makes the simplifier eliminate a redundant seq like
case x of y -> ...y....
where y is used strictly. GHC used to do this, but I made it less
aggressive in
commit 28d9a03253e8fd613667526a170b684f2017d299 (Jan 2013)
However #8900 shows that doing so sometimes loses good
transformations; and the transformation is valid according to "A
semantics for imprecise exceptions". So I'm restoring the old
behaviour.
See Note [Eliminating redundant seqs]
|
| |
|
|
|
|
|
|
|
|
|
| |
For DFunUnfoldings we were failing to occurrence-analyse the unfolding,
and that meant that a loop breaker wasn't marked as such, which in turn
meant it was inlined away when it still had occurrence sites. See
Note [Occurrrence analysis of unfoldings] in CoreUnfold.
This is a pretty long-standing bug, happily nailed by John Lato.
|