summaryrefslogtreecommitdiff
path: root/compiler/simplCore
Commit message (Collapse)AuthorAgeFilesLines
* Implement typechecker pluginsAdam Gundry2014-11-202-71/+8
| | | | | | | | | | | | | | | | | | | | 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
* Turn CoreWriter into a newtype; fix commentDavid Feuer2014-11-191-8/+11
| | | | | | | | | | | | | | | 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
* Improve Applicative definitionsDavid Feuer2014-11-071-1/+2
| | | | | | | | | | | | | | | | | | | | | 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
* Remove -ddump-core-pipeline flagJan Stolarek2014-11-062-5/+1
|
* Remove -ddump-simpl-phases flagJan Stolarek2014-11-062-38/+11
|
* Add comments explaining ProbOneShotSimon Peyton Jones2014-11-042-2/+3
|
* Some refactoring around endPass and debug dumpingSimon Peyton Jones2014-11-044-31/+55
| | | | | I forget all the details, but I spent some time trying to understand the current setup, and tried to simplify it a bit
* Fix comment typosJan Stolarek2014-10-312-3/+3
|
* Comments onlyJan Stolarek2014-10-301-1/+1
|
* Fix comment typos: lll -> ll, THe -> TheJan Stolarek2014-10-142-2/+2
|
* [ci skip] compiler: Kill last remaining tabs in CallArityAustin Seipp2014-10-011-2/+2
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Simplify mergeSATInfo by using zipWithDavid Feuer2014-10-011-9/+18
| | | | Closes #9561.
* Fix bogus commentSimon Peyton Jones2014-10-011-2/+2
|
* Stop exporting, and stop using, functions marked as deprecatedThomas Miedema2014-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* De-tabify and remove trailing whitespaceSimon Peyton Jones2014-09-262-263/+251
|
* [ci skip] simplCore: detabify/dewhitespace CoreMonadAustin Seipp2014-09-251-217/+211
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Ensure that loop breakers are computed when glommingSimon Peyton Jones2014-09-231-12/+30
| | | | | | | | | | | | | | | | | 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.
* Fix garbled comment wordingSimon Peyton Jones2014-09-191-2/+3
| | | | Thanks to Gabor for pointing this out
* Use mapAccumL (refactoring only)Simon Peyton Jones2014-09-191-8/+1
| | | | Fixes Trac #9529
* Make Applicative a superclass of MonadAustin Seipp2014-09-091-4/+4
| | | | | | | | | | | | | | | | | | | | | 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
* Typos in commentsGabor Greif2014-08-291-2/+2
|
* When finding loop breakers, distinguish INLINE from INLINEABLESimon Peyton Jones2014-08-291-36/+19
| | | | | | 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.
* Comments, white space, and rename "InlineRule" to "stable unfolding"Simon Peyton Jones2014-08-293-42/+42
| | | | | | 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
* Fix a bug in CSE, for INLINE/INLNEABLE thingsSimon Peyton Jones2014-08-291-44/+40
| | | | | | | | | | | | 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.
* Define mapUnionVarSet, and use itSimon Peyton Jones2014-08-293-8/+8
| | | | Call sites are much easier to understand than before
* Simple refactor of the case-of-case transformSimon Peyton Jones2014-08-281-17/+11
| | | | More modular, less code. No change in behaviour.
* Run float-inwards immediately before the strictness analyser.Simon Peyton Jones2014-08-281-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Comments onlySimon Peyton Jones2014-08-281-0/+3
|
* Don't float out (classop dict e1 e2)Simon Peyton Jones2014-08-283-17/+30
| | | | | | | | | | | 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.
* Refactor unfoldingsSimon Peyton Jones2014-08-281-5/+5
| | | | | | | | | | | | | | | | | | | | 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.
* Less voluminous output when printing continuationsSimon Peyton Jones2014-08-281-1/+1
|
* simplCore: detabify/dewhitespace LiberateCaseAustin Seipp2014-08-201-128/+120
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* simplCore: detabify/dewhitespace SetLevelsAustin Seipp2014-08-201-272/+264
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* simplCore: detabify/dewhitespace SATAustin Seipp2014-08-201-62/+54
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* This note's name has been fixedGabor Greif2014-08-191-1/+1
|
* Fix three problems with occurrence analysis on case alternatives.Andrew Farmer2014-08-181-21/+32
| | | | | | | | | | | | | | | | | | | | | 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
* Refactor the handling of case-eliminationSimon Peyton Jones2014-08-071-59/+60
| | | | | | 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.
* Extensive Notes on can_fail and has_side_effectsSimon Peyton Jones2014-08-071-0/+1
| | | | | | | | | | | | | | | | | | | | 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.
* Document the maintenance of the let/app invariant in the simplifierSimon Peyton Jones2014-08-073-47/+65
| | | | | | | | | 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.
* Don't float into unlifted function argumentsSimon Peyton Jones2014-08-071-20/+52
| | | | | We were inadvertently destroying the let/app invariant, by floating into an unlifted function argument.
* Move Outputable instance for FloatBind to the data type definitionSimon Peyton Jones2014-08-071-5/+0
|
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-1512-9/+24
| | | | | | | | | | | | | | | | | | 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.
* Improve tracing in SimplifierSimon Peyton Jones2014-05-081-17/+18
|
* Some typos in commentsGabor Greif2014-04-241-1/+1
|
* Don't eta-expand PAPs (fixes Trac #9020)Simon Peyton Jones2014-04-241-11/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Allow a longer demand signature than aritySimon Peyton Jones2014-04-081-3/+2
| | | | | | | | | | 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.
* Typos in commentsGabor Greif2014-03-251-2/+2
|
* Eliminate redundant seq's (Trac #8900)Simon Peyton Jones2014-03-241-44/+55
| | | | | | | | | | | | | | | | 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]
* Comments onlySimon Peyton Jones2014-03-241-5/+5
|
* Make sure we occurrence-analyse unfoldings (fixes Trac #8892)Simon Peyton Jones2014-03-181-40/+38
| | | | | | | | | 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.