summaryrefslogtreecommitdiff
path: root/compiler/simplCore/OccurAnal.hs
Commit message (Collapse)AuthorAgeFilesLines
* Modules: Core operations (#13009)Sylvain Henry2020-03-181-2898/+0
|
* Modules: Core (#13009)Sylvain Henry2020-03-161-2/+2
| | | | Update submodule: haddock
* Modules: Core (#13009)Sylvain Henry2020-02-261-7/+7
| | | | Update haddock submodule
* Fix #17724 by having occAnal preserve used bindings.Andreas Klebinger2020-02-201-1/+6
| | | | | | It sometimes happened that occAnal would remove bindings as dead code by relying on bindings to be in dependency order. The fix was contributed by SPJ.
* Disable two warnings for files that trigger themTom Ellis2020-01-271-0/+2
| | | | | | 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-6/+6
|
* Module hierarchy: Iface (cf #13009)Sylvain Henry2020-01-061-2/+2
|
* Fix typos, using Wikipedia list of common typosBrian Wignall2019-11-281-5/+5
|
* Reduce boolean blindness in OccInfo(OneOcc) #17482Philipp Krüger2019-11-281-10/+10
| | | | | | | | | | | | | * Transformed the type aliases `InterestingCxt`, `InsideLam` and `OneBranch` into data types. * Added Semigroup and Monoid instances for use in orOccInfo in OccurAnal.hs * Simplified some usage sites by using pattern matching instead of boolean algebra. Metric Increase: T12150 This increase was on a Mac-build of exactly 1%. This commit does *not* re-intruduce the asymptotic memory usage described in T12150.
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-151-11/+11
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Don't do binder-swap for GlobalIdsSimon Peyton Jones2019-02-221-3/+8
| | | | | | | | | | | | This patch disables the binder-swap transformation in the (relatively rare) case when the scrutinee is a GlobalId. Reason: we are getting Lint errors so that GHC doesn't even validate. Trac #16346. This is NOT the final solution -- it's just a stop-gap to get us running again. The final solution is in Trac #16296
* Comments only about the binder-swap in OccurAnalSimon Peyton Jones2019-02-081-12/+41
|
* Stomp a few typos and grammarosGabor Greif2018-12-171-1/+1
| | | | Also use 'id'
* Do not mark CoVars as dead in the occur-analSimon Peyton Jones2018-10-041-0/+23
| | | | | | | | For years we have been marking CoVars as dead, becuase we don't gather occurrence info from types. This is obviously wrong and caused Trac #15695. See Note [Do not mark CoVars as dead] in OccurAnal.
* Replace most occurences of foldl with foldl'.klebinger.andreas@gmx.at2018-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds foldl' to GhcPrelude and changes must occurences of foldl to foldl'. This leads to better performance especially for quick builds where GHC does not perform strictness analysis. It does change strictness behaviour when we use foldl' to turn a argument list into function applications. But this is only a drawback if code looks ONLY at the last argument but not at the first. And as the benchmarks show leads to fewer allocations in practice at O2. Compiler performance for Nofib: O2 Allocations: -1 s.d. ----- -0.0% +1 s.d. ----- -0.0% Average ----- -0.0% O2 Compile Time: -1 s.d. ----- -2.8% +1 s.d. ----- +1.3% Average ----- -0.8% O0 Allocations: -1 s.d. ----- -0.2% +1 s.d. ----- -0.1% Average ----- -0.2% Test Plan: ci Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal Reviewed By: bgamari, monoidal Subscribers: tdammers, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4929
* More misc commentsSimon Peyton Jones2018-06-251-0/+3
| | | | | ... plus, reorder equations in toIfaceVar to improve legibility. No change in behaviour.
* Remove ad-hoc special case in occAnalSimon Peyton Jones2018-06-071-39/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 1999 I put this ad-hoc code in the Case-handling code for occAnal: occAnal env (Case scrut bndr ty alts) = ... -- Note [Case binder usage] -- ~~~~~~~~~~~~~~~~~~~~~~~~ -- The case binder gets a usage of either "many" or "dead", never "one". -- Reason: we like to inline single occurrences, to eliminate a binding, -- but inlining a case binder *doesn't* eliminate a binding. -- We *don't* want to transform -- case x of w { (p,q) -> f w } -- into -- case x of w { (p,q) -> f (p,q) } tag_case_bndr usage bndr = (usage', setIdOccInfo bndr final_occ_info) where occ_info = lookupDetails usage bndr usage' = usage `delDetails` bndr final_occ_info = case occ_info of IAmDead -> IAmDead _ -> noOccInfo But the comment looks wrong -- the bad inlining will not happen -- and I think it relates to some long-ago version of the simplifier. So I simply removed the special case, which gives more accurate occurrence-info to the case binder. Interestingly I got a slight improvement in nofib binary sizes. -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- cacheprof -0.1% +0.2% -0.7% -1.2% +8.6% -------------------------------------------------------------------------------- Min -0.2% 0.0% -14.5% -30.5% 0.0% Max -0.1% +0.2% +10.0% +10.0% +25.0% Geometric Mean -0.2% +0.0% -1.9% -5.4% +0.3% I have no idea if the improvement in runtime is real. I did look at the tiny increase in allocation for cacheprof and concluded that it was unimportant (I forget the details). Also the more accurate occ-info for the case binder meant that some inlining happens in one pass that previously took successive passes for the test dependent/should_compile/dynamic-paper (which has a known Russel-paradox infinite loop in the simplifier). In short, a small win: less ad-hoc complexity and slightly smaller binaries.
* vectorise: Put it out of its miseryBen Gamari2018-06-021-8/+4
| | | | | | | | | | | | | | | | | | | | | Poor DPH and its vectoriser have long been languishing; sadly it seems there is little chance that the effort will be rekindled. Every few years we discuss what to do with this mass of code and at least once we have agreed that it should be archived on a branch and removed from `master`. Here we do just that, eliminating heaps of dead code in the process. Here we drop the ParallelArrays extension, the vectoriser, and the `vector` and `primitive` submodules. Test Plan: Validate Reviewers: simonpj, simonmar, hvr, goldfire, alanz Reviewed By: simonmar Subscribers: goldfire, rwbarton, thomie, mpickering, carter Differential Revision: https://phabricator.haskell.org/D4761
* Refactor in OccurAnalSimon Peyton Jones2018-04-271-28/+29
| | | | | | | | | * (+++) --> andUDs * combineAltsUsageDetails --> orUDs * combineUsageDetailsList --> andUDsList * Change some andUDsList to a fold for efficiency No change in behaviour
* White space onlySimon Peyton Jones2018-03-271-0/+4
|
* Typos in commentsGabor Greif2018-01-171-1/+1
|
* Fix join-point decisionSimon Peyton Jones2018-01-091-11/+57
| | | | | | | | | | | | | This patch moves the "ok_unfolding" test from CoreOpt.joinPointBinding_maybe to OccurAnal.decideJoinPointHood Previously the occurrence analyser was deciding to make something a join point, but the simplifier was reversing that decision, which made the decision about /other/ bindings invalid. Fixes Trac #14650.
* Remove a bogus warningSimon Peyton Jones2018-01-091-1/+6
| | | | | | The new comment explains why this warning can legitimately fire, so I've removed it entirely. Lint will cath any bad cases.
* Comments about join point typesSimon Peyton Jones2018-01-031-37/+4
| | | | ...provked by #14620
* Occurrrence analysis improvements for NOINLINE functionsSimon Peyton Jones2017-12-081-21/+33
| | | | | | | | | This patch fixes #14567. The idea is simple: if a function is marked NOINLINE then it makes a great candidate for a loop breaker. Implementation is easy too, but it needs a little extra plubming, notably the occ_unf_act field in OccEnv
* 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
* OccurAnal: Ensure SourceNotes don't interfere with join-point analysisBen Gamari2017-09-191-0/+7
| | | | | | | | | | | | | | | | | | | | | In general ticks are problematic for join point analysis as described in #14242. However, source notes are intended to be a best-effort annotation which shouldn't interfere with optimization. Special-case these to ensure that tail-call information is still correct, even in the presence of source note ticks. Test Plan: Validate Reviewers: simonpj, austin Reviewed By: simonpj Subscribers: rwbarton, thomie GHC Trac Issues: #14242 Differential Revision: https://phabricator.haskell.org/D3978
* Fix typos in diagnostics, testsuite and commentsGabor Greif2017-09-071-1/+1
|
* Don't do the RhsCtxt thing for join pointsSimon Peyton Jones2017-08-251-4/+20
| | | | | | This minor change fixes Trac #14137. It is described in Note [Join point RHSs] in OccurAnal
* Bottoming expressions should not be expandableSimon Peyton Jones2017-08-251-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | This patch changes isExpandableApp and isWorkFreeApp to respond False to bottoming applications. I found that if we had x = undefined <dict-expr> then prepareRhs was ANF'ing it to d = <dict-expr> x = undefined d which is stupid (no gain); and worse it made the simplifier iterate indefinitely. It showed up when I started marking 'x' as a bottoming Id more aggresssively than before; but it's been a lurking bug for ages. It was convenient to make isWorkFreeApp also return False for bottoming applications, and I see no reason not to do so. That leaves isCheapApp. It currently replies True to bottoming applications, but I don't see why that's good.. Something to try later.
* Tracing in OccAnal (commented out)Simon Peyton Jones2017-08-181-3/+4
|
* Simplify OccurAnal.tagRecBindersJoachim Breitner2017-08-011-6/+3
| | | | | | | No need to mark the binders with markNonTailCalled, as they already have been marked as such in rhs_udss' via adjust. Differential Revision: https://phabricator.haskell.org/D3810
* Use lengthIs and friends in more placesRyan Scott2017-06-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | While investigating #12545, I discovered several places in the code that performed length-checks like so: ``` length ts == 4 ``` This is not ideal, since the length of `ts` could be much longer than 4, and we'd be doing way more work than necessary! There are already a slew of helper functions in `Util` such as `lengthIs` that are designed to do this efficiently, so I found every place where they ought to be used and did just that. I also defined a couple more utility functions for list length that were common patterns (e.g., `ltLength`). Test Plan: ./validate Reviewers: austin, hvr, goldfire, bgamari, simonmar Reviewed By: bgamari, simonmar Subscribers: goldfire, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3622
* Replace Digraph's Node type synonym with a data typeMatthew Pickering2017-04-041-9/+12
| | | | | | | | | | | | | This refactoring makes it more obvious when we are constructing a Node for the digraph rather than a less useful 3-tuple. Reviewers: austin, goldfire, bgamari, simonmar, dfeuer Reviewed By: dfeuer Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3414
* Improve tracing in OccurAnalMatthew Pickering2017-03-241-1/+1
| | | | | | | | | | | | | One commented out tracing function didn't type check and also show the scores of loop breaker nodes. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3371
* OccurAnal.hs: Add an assert for an invariantÖmer Sinan Ağacan2017-03-191-1/+2
| | | | | | | | | | Reviewers: austin, bgamari, dfeuer Reviewed By: bgamari, dfeuer Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3360
* OccurAnal.hs: Fix "Adjusting for lambdas" note nameÖmer Sinan Ağacan2017-03-181-2/+2
|
* Tiny refactorSimon Peyton Jones2017-03-061-2/+3
|
* Upgrade UniqSet to a newtypeDavid Feuer2017-03-011-9/+11
| | | | | | | | | | | | | | | | | | | | | The fundamental problem with `type UniqSet = UniqFM` is that `UniqSet` has a key invariant `UniqFM` does not. For example, `fmap` over `UniqSet` will generally produce nonsense. * Upgrade `UniqSet` from a type synonym to a newtype. * Remove unused and shady `extendVarSet_C` and `addOneToUniqSet_C`. * Use cached unique in `tyConsOfType` by replacing `unitNameEnv (tyConName tc) tc` with `unitUniqSet tc`. Reviewers: austin, hvr, goldfire, simonmar, niteria, bgamari Reviewed By: niteria Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3146
* Mark non-recursive join lambdas as one-shotSimon Peyton Jones2017-02-281-27/+41
| | | | | | | | | | | | | | | | | | | When we have join j x y = rhs in ... we know that the lambdas for 'x' and 'y' are one-shot. Let's mark them as such! This doesn't fix a specific bug, but it feels right to me. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: lukemaurer, thomie Differential Revision: https://phabricator.haskell.org/D3196
* Comments and tiny refactor onlySimon Peyton Jones2017-02-161-11/+17
|
* Typos in notes and comments [ci skip]Gabor Greif2017-02-131-3/+3
|
* Improve the Occurrence Analyzer’s handling of one-shot functionsJoachim Breitner2017-02-111-21/+59
| | | | | | | | | | | | | | | | | | | | | When determining whether an expression is used saturatedly, count the number of value arguments that the occurrence analyser sees, and add the number of one-shot arguments that we know (from the strictness analyser) are passed from the context. perf results suggest no noticable change in allocations, reduction of code sizes, and performance regression possibliy due to loss of join points. Test Plan: perf.haskell.org Reviewers: simonpj, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3089
* Tweaks and typos in manual, note refs, commentsGabor Greif2017-02-091-1/+1
|
* More typos in comments [skip ci]Gabor Greif2017-02-081-2/+2
|
* Fixes for OccurAnal bugs (#13221)Luke Maurer2017-02-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - OccurAnal: When checking tail calls, count rule's LHS args, not bndrs Pretty obvious error in retrospect: ``` let $sj = \y ys -> ... {-# RULES "SC:j" forall y ys. j (y:ys) = $sj y ys #-} j = \xs -> ... in ... ``` A jump on the RHS of a rule for a join point is only okay if the rule's LHS is saturated - in this case, since the LHS is j (y:ys) and j takes one argument, both j and $sj can become join points. See Note [Rules and join points] in OccurAnal. By mistake, OccAnal was counting the rule's binders (y and ys) rather than the args in its LHS, so $sj wasn't being made a join point. - Don't zap tail calls in unfoldings This was causing T7796 to squeal about join points not being rediscovered. Reviewers: bgamari, austin Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3080
* Get rid of ProbOneShotJoachim Breitner2017-02-031-1/+1
| | | | | | | This fixes #13227. It remains to be seen what the performance impacts are. Pushing as a branch to get perf.haskell.org answer that for us. Differential Revision: https://phabricator.haskell.org/D3067
* Join pointsLuke Maurer2017-02-011-215/+741
| | | | | | | | | | | | | | | | | | | 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-3/+3
|
* Typos in comments only [ci skip]Gabor Greif2017-01-181-1/+1
|