summaryrefslogtreecommitdiff
path: root/compiler/simplCore/CSE.hs
Commit message (Collapse)AuthorAgeFilesLines
* Modules: Core operations (#13009)Sylvain Henry2020-03-181-799/+0
|
* Modules: Core (#13009)Sylvain Henry2020-03-161-3/+3
| | | | Update submodule: haddock
* Improve CSE.combineAltsSimon Peyton Jones2020-03-141-21/+74
| | | | | | | | | | | | | This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642
* Typos in comments [skip ci]Krzysztof Gogolewski2020-03-101-1/+1
|
* Modules: Core (#13009)Sylvain Henry2020-02-261-8/+8
| | | | Update haddock submodule
* Disable two warnings for files that trigger themTom Ellis2020-01-271-0/+3
| | | | | | incomplete-uni-patterns and incomplete-record-updates will be in -Wall at a future date, so prepare for that by disabling those warnings on files that trigger them.
* Fix more typos, via an improved Levenshtein-style correctorBrian Wignall2020-01-121-3/+3
|
* Fix typos, using Wikipedia list of common typosBrian Wignall2019-11-281-1/+1
|
* Make CSE delay inlining lessSimon Peyton Jones2019-11-011-7/+49
| | | | | | | | | CSE delays inlining a little bit, to avoid losing vital specialisations; see Note [Delay inlining after CSE] in CSE. But it was being over-enthusiastic. This patch makes the delay only apply to Ids with specialisation rules, which avoids unnecessary delay (#17409).
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-151-5/+5
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Preserve specialisations despite CSESimon Peyton Jones2018-09-051-11/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trac #15445 showed that, as a result of CSE, a function with an automatically generated specialisation RULE could be inlined before the RULE had a chance to fire. This patch attaches a NOINLINE[2] activation to the Id, during CSE, to stop this happening. See Note [Delay inlining after CSE] ---- Historical note --- This patch is simpler and more direct than an earlier version: commit 2110738b280543698407924a16ac92b6d804dc36 Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Mon Jul 30 13:43:56 2018 +0100 Don't inline functions with RULES too early We had to revert this patch because it made GHC itself slower. Why? It delayed inlining of /all/ functions with RULES, and that was very bad in TcFlatten.flatten_ty_con_app * It delayed inlining of liftM * That delayed the unravelling of the recursion in some dictionary bindings. * That delayed some eta expansion, leaving flatten_ty_con_app = \x y. let <stuff> in \z. blah * That allowed the float-out pass to put sguff between the \y and \z. * And that permanently stopped eta expasion of the function, even once <stuff> was simplified. -- End of historical note ---
* Split TrieMap into a general (TrieMap) and core specific (CoreTrieMap) module.klebinger.andreas@gmx.at2018-05-051-1/+1
| | | | | | | | | | | | | | | | | | Splitting TrieMap into a general and core specific part allows us to define instances for TrieMap without creating a transitive dependency on CoreSyn. Test Plan: ci Reviewers: goldfire, bgamari, simonmar, simonpj Reviewed By: bgamari, simonpj Subscribers: simonpj, nomeata, thomie, carter GHC Trac Issues: #15082 Differential Revision: https://phabricator.haskell.org/D4618
* Minor comments in CSESimon Peyton Jones2018-04-171-8/+8
|
* CSE: Walk past join point lambdas (#15002)Joachim Breitner2018-04-091-2/+32
| | | | | | | | | | | | As the CSE transformation traverses the syntax tree, it needs to go past the lambdas of a join point, and only look for CSE opportunities inside, as a join point’s lambdas must be preserved. Simple fix; comes with a Note and a test case. Thanks to Ryan Scott for an excellently minimized test case, and for bisecting GHC. Differential Revision: https://phabricator.haskell.org/D4572
* Allow top level ticked string literalsBartosz Nitka2018-03-061-2/+2
| | | | | | | | | | | | | | | | | | | | This reverts f5b275a239d2554c4da0b7621211642bf3b10650 and changes the places that looked for `Lit (MachStr _))` to use `exprIsMbTickedLitString_maybe` to unwrap ticks as necessary. Also updated relevant comments. Test Plan: I added 3 new tests that previously reproduced. GHC HEAD now builds with -g Reviewers: simonpj, simonmar, bgamari, hvr, goldfire Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14779 Differential Revision: https://phabricator.haskell.org/D4470
* Typos in commentsGabor Greif2017-12-211-1/+1
|
* Get rid of some stuttering in comments and docsGabor Greif2017-12-191-1/+1
|
* Fix grammaros in commentsGabor Greif2017-10-171-1/+1
|
* compiler: introduce custom "GhcPrelude" PreludeHerbert Valerio Riedel2017-09-191-0/+2
| | | | | | | | | | | | | | | | | | This switches the compiler/ component to get compiled with -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all modules. This is motivated by the upcoming "Prelude" re-export of `Semigroup((<>))` which would cause lots of name clashes in every modulewhich imports also `Outputable` Reviewers: austin, goldfire, bgamari, alanz, simonmar Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari Differential Revision: https://phabricator.haskell.org/D3989
* Allow CSE'ing of work-wrapped bindings (#14186)Joachim Breitner2017-09-121-2/+8
| | | | | | | | the worker/wrapper creates an artificial INLINE pragma, which caused CSE to not do its work. We now recognize such artificial pragmas by using `NoUserInline` instead of `Inline` as the `InlineSpec`. Differential Revision: https://phabricator.haskell.org/D3939
* CSE.cseOneExpr: Set InScopeSet correctlyJoachim Breitner2017-08-181-2/+8
| | | | | because this is a convenience function for API users, calculate the in-scope set from `exprFreeVars`.
* Do a bit more CSESimon Peyton Jones2017-07-311-1/+1
| | | | | | | | I discovered that in let x = MkT y in ....(MKT y |> co).... we weren't CSE'ing the (MkT y). The fix is easy.
* Handle type-lets betterSimon Peyton Jones2017-05-171-5/+9
| | | | | | | | | | | | | | | Core allows non-recursive type-lets, thus let a = TYPE ty in ... They are substituted away very quickly, but it's convenient for some passes to produce them (rather than to have to substitute immediately). Trac #13708 tried the effect of not running the simplifer at all (a rather bizarre thing to do, but still). That showed that some passes crashed because they always treated a let-bounder binder as an Id. This patch adds some easy fixes.
* CSE: Fix cut and paste errorBen Gamari2017-04-281-2/+2
| | | | | | | | | | | | | extendCSRecEnv took the map to be extended from cs_map instead of cs_rec_map. Oops! Test Plan: Validate Reviewers: simonpj, austin Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3510
* Minor comment updates on CSE.Edward Z. Yang2017-04-021-3/+13
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Fix CSE (again) on literal stringsSimon Peyton Jones2017-03-061-35/+44
| | | | Fixes Trac #13367. See Note [Take care with literal strings]
* Comments only, in CSE (#13340)Reid Barton2017-03-031-3/+9
| | | | | | | | | | Reviewers: simonpj, austin, bgamari, dfeuer Reviewed By: dfeuer Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3268
* Move isJoinId, isJoinId_maybe to IdSimon Peyton Jones2017-02-281-2/+3
| | | | | | | | | | | | | | | | | | This is just a refactoring, moving these two functions where they belong. The reason they were there was because of the use of isJoinId_maybe in the OutputableBndr instance of TaggedBndr, which was in CoreSyn. I moved it to PprCore, to join the OutputableBndr instance for Var. That makes more sense anyway. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3207
* Fix redundant import in CSEDavid Feuer2017-02-281-1/+1
|
* Combine identical case alternatives in CSESimon Peyton Jones2017-02-281-18/+114
| | | | | | | | | | | | See Note [Combine case alternatives] in CSE. This opportunity surfaced when I was was studying early inlining. It's easy (and cheap) to exploit, and sometimes makes a worthwhile saving. Reviewers: austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3194
* Fix a substitution bug in cseCaseSimon Peyton Jones2017-02-171-1/+2
| | | | | There was a missing substTy in cseCase! Wow. I'm surprised it has not caused problems. Anyway, easily fixed.
* Expose cseExpr from CSEJoachim Breitner2017-02-041-1/+4
| | | | | | for the benefit of GHC API users who want to CSE single expressions. Differential Revision: https://phabricator.haskell.org/D3069
* Join pointsLuke Maurer2017-02-011-1/+15
| | | | | | | | | | | | | | | | | | | This major patch implements Join Points, as described in https://ghc.haskell.org/trac/ghc/wiki/SequentCore. You have to read that page, and especially the paper it links to, to understand what's going on; but it is very cool. It's Luke Maurer's work, but done in close collaboration with Simon PJ. This Phab is a squash-merge of wip/join-points branch of http://github.com/lukemaurer/ghc. There are many, many interdependent changes. Reviewers: goldfire, mpickering, bgamari, simonmar, dfeuer, austin Subscribers: simonpj, dfeuer, mpickering, Mikolaj, thomie Differential Revision: https://phabricator.haskell.org/D2853
* Typos and grammar in manual/commentsGabor Greif2017-01-231-1/+1
|
* Allow top-level string literals in Core (#8472)Takano Akio2017-01-201-13/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commits relaxes the invariants of the Core syntax so that a top-level variable can be bound to a primitive string literal of type Addr#. This commit: * Relaxes the invatiants of the Core, and allows top-level bindings whose type is Addr# as long as their RHS is either a primitive string literal or another variable. * Allows the simplifier and the full-laziness transformer to float out primitive string literals to the top leve. * Introduces the new StgGenTopBinding type to accomodate top-level Addr# bindings. * Introduces a new type of labels in the object code, with the suffix "_bytes", for exported top-level Addr# bindings. * Makes some built-in rules more robust. This was necessary to keep them functional after the above changes. This is a continuation of D2554. Rebasing notes: This had two slightly suspicious performance regressions: * T12425: bytes allocated regressed by roughly 5% * T4029: bytes allocated regressed by a bit over 1% * T13035: bytes allocated regressed by a bit over 5% These deserve additional investigation. Rebased by: bgamari. Test Plan: ./validate --slow Reviewers: goldfire, trofi, simonmar, simonpj, austin, hvr, bgamari Reviewed By: trofi, simonpj, bgamari Subscribers: trofi, simonpj, gridaphobe, thomie Differential Revision: https://phabricator.haskell.org/D2605 GHC Trac Issues: #8472
* Simplify and improve CSESimon Peyton Jones2017-01-201-31/+39
| | | | | | | | | Trac #13156 showed a lost opportunity for CSE. I found that it was easy to fix, and it had the nice side effect of rendering a previous nasty case, described in Note [Corner case for case expressions], unnecessary. Simpler code, does more. Great.
* Minor refactoring in CSESimon Peyton Jones2017-01-051-34/+46
| | | | | | | I noticed that CSE.addBinding was always returning one of its own inputs, so I refactored to avoid doing so. No change in behaviour.
* Move InId/OutId to CoreSynSimon Peyton Jones2016-12-211-10/+1
| | | | | | | | It turned out that many different modules defined the same type synonyms (InId, OutId, InType, OutType, etc) for the same purpose. This patch is refactoring only: it moves all those definitions to CoreSyn.
* Fix a long-standing bug in CSESimon Peyton Jones2016-12-121-13/+23
| | | | | | | | | I had the environments wrong so that CSE could mis-clone an expression, if the uniques just happened to be badly arranged. It's hard to trigger the bug, so I can't make a reliable test case. Happily the fix is easy.
* Spelling in commentsGabor Greif2016-05-251-1/+1
|
* CSE code cleanup and improvementSimon Peyton Jones2016-04-061-112/+189
| | | | | | | | | Triggered by an observation by Joachim, Simon felt the urge to clean up the CSE code a bit. This is the result. (Code by Simon, commit message and other leg-work by Joachim) Differential Revision: https://phabricator.haskell.org/D2074
* Tidy up handling of coercion variablesSimon Peyton Jones2016-03-241-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Comments to explain that a CoVar, whose IdInfo is CoVarId, is always unlifted (but may be nominal or representational role) And TyCoRep.isCoercionType picks out only those unlifted types, NOT the lifted versions * Introduce Var.NcId for non-co-var Ids with predicate isNonCoVarId * Add assertions in CoreSubst that the Id env is only used for NcIds * Fix lurking bug in CSE which extended the CoreSubst Id env with a CoVar * Fix two bugs in Specialise.spec_call, which wrongly treated CoVars like NcIds - needed a varToCoreExpr in one place - needed extendSubst not extendIdSubst in another This was the root cause of Trac #11644 Minor refactoring * Eliminate unused mkDerivedLocalCoVarM, mkUserLocalCoVar * Small refactor in mkSysLocalOrCoVar
* Add kind equalities to GHC.Richard Eisenberg2015-12-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the ideas originally put forward in "System FC with Explicit Kind Equality" (ICFP'13). There are several noteworthy changes with this patch: * We now have casts in types. These change the kind of a type. See new constructor `CastTy`. * All types and all constructors can be promoted. This includes GADT constructors. GADT pattern matches take place in type family equations. In Core, types can now be applied to coercions via the `CoercionTy` constructor. * Coercions can now be heterogeneous, relating types of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2` proves both that `t1` and `t2` are the same and also that `k1` and `k2` are the same. * The `Coercion` type has been significantly enhanced. The documentation in `docs/core-spec/core-spec.pdf` reflects the new reality. * The type of `*` is now `*`. No more `BOX`. * Users can write explicit kind variables in their code, anywhere they can write type variables. For backward compatibility, automatic inference of kind-variable binding is still permitted. * The new extension `TypeInType` turns on the new user-facing features. * Type families and synonyms are now promoted to kinds. This causes trouble with parsing `*`, leading to the somewhat awkward new `HsAppsTy` constructor for `HsType`. This is dispatched with in the renamer, where the kind `*` can be told apart from a type-level multiplication operator. Without `-XTypeInType` the old behavior persists. With `-XTypeInType`, you need to import `Data.Kind` to get `*`, also known as `Type`. * The kind-checking algorithms in TcHsType have been significantly rewritten to allow for enhanced kinds. * The new features are still quite experimental and may be in flux. * TODO: Several open tickets: #11195, #11196, #11197, #11198, #11203. * TODO: Update user manual. Tickets addressed: #9017, #9173, #7961, #10524, #8566, #11142. Updates Haddock submodule.
* Spelling in commentSimon Peyton Jones2015-04-211-1/+1
|
* Zap usage info in CSE (Trac #10218)Simon Peyton Jones2015-04-141-12/+23
| | | | | | | | | | | | | | | | | Trac #10218 reports a subtle bug that turned out to be: - CSE invalidated the usage information computed by earlier demand analysis, by increasing sharing - that made a single-entry thunk into a multi-entry thunk - and with -feager-blackholing, that led to <<loop>> The patch fixes it by making the CSE pass zap usage information for let-bound identifiers. It can be restored by -flate-dmd-anal. (But making -flate-dmd-anal the default needs some careful work; see Trac #7782.)
* Split stripTicks into expression editing and tick collectionPeter Wortmann2015-01-191-4/+6
| | | | | | | | As with stripTicksTop, this is because we often need the stripped expression but not the ticks (at least not right away). This makes a big difference for CSE, see #9961. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Source notes (Core support)Peter Wortmann2014-12-161-9/+19
| | | | | | | | | | | | | | | | | | | | | | This patch introduces "SourceNote" tickishs that link Core to the source code that generated it. The idea is to retain these source code links throughout code transformations so we can eventually relate object code all the way back to the original source (which we can, say, encode as DWARF information to allow debugging). We generate these SourceNotes like other tickshs in the desugaring phase. The activating command line flag is "-g", consistent with the flag other compilers use to decide DWARF generation. Keeping ticks from getting into the way of Core transformations is tricky, but doable. The changes in this patch produce identical Core in all cases I tested -- which at this point is GHC, all libraries and nofib. Also note that this pass creates *lots* of tick nodes, which we reduce somewhat by removing duplicated and overlapping source ticks. This will still cause significant Tick "clumps" - a possible future optimization could be to make Tick carry a list of Tickishs instead of one at a time. (From Phabricator D169)
* compiler: de-lhs simplCore/Austin Seipp2014-12-031-0/+313
Signed-off-by: Austin Seipp <austin@well-typed.com>