summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SimplEnv.lhs
Commit message (Collapse)AuthorAgeFilesLines
...
* Substantial improvement to the interaction of RULES and inliningsimonpj@microsoft.com2007-10-291-21/+17
| | | | | | | | | | | | | | | | (Merge to 6.8 branch after testing.) There were a number of delicate interactions between RULEs and inlining in GHC 6.6. I've wanted to fix this for a long time, and some perf problems in the 6.8 release candidate finally forced me over the edge! The issues are documented extensively in OccurAnal, Note [Loop breaking and RULES], and I won't duplicate them here. (Many of the extra lines in OccurAnal are comments!) This patch resolves Trac bugs #1709, #1794, #1763, I believe.
* Fix CodingStyle#Warnings URLsIan Lynagh2007-09-041-1/+1
|
* Use OPTIONS rather than OPTIONS_GHC for pragmasIan Lynagh2007-09-031-2/+2
| | | | | | | Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
* Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modulesIan Lynagh2007-09-011-0/+7
|
* Remove mapAccumL, mapAccumR, mapAccumBIan Lynagh2007-07-021-0/+2
| | | | | mapAccumL and mapAccumR are in Data.List now. mapAccumB is unused.
* Improve the interaction of 'seq' and associated data typessimonpj@microsoft.com2007-05-231-12/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Roman produced programs involving associated types that did not optimise well. His programs were something like this: data family T a data instance T Int = MkT Bool Char bar :: T Int -> Int bar t = t `seq` loop 0 where loop = ... You'd think that the `seq` should unbox 't' outside the loop, since a (T Int) is just a MkT pair. The most robust way to make this happen is for the simplifier to understand a bit about type-family instances. See Note [Improving seq] in Simplify.lhs. We use FamInstEnv.topNormaliseType to do the interesting work. To make this happen I did a bit of refactoring to the simplifier monad. I'd previously done a very similar transformation in LiberateCase, but it was happening too late. So this patch takes it out of LiberateCase as well as adding it to Simplify.
* Make let-floating work even if there are big lambdas in the waysimonpj@microsoft.com2007-05-071-18/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch generalises the let-floating transformation in a way suggested by Roman and Manuel when doing closure conversion. There are extensive comments in Note [Floating and type abstraction], which begins thus. Consider this: x = /\a. C e1 e2 We'd like to float this to y1 = /\a. e1 y2 = /\a. e2 x = /\a. C (y1 a) (y2 a) for the usual reasons: we want to inline x rather vigorously. (Further commennts follow in SimplUtils.) The implementation is not hard; indeed it used to be in GHC years ago. I removed it thinking that full laziness would achieve the same effect, but I'm not sure it does; and in any case it seems more direct to do it here. The transformation should not make anything worse, so yell if you see anything unexpected happening.
* Use Id.isStrictIdsimonpj@microsoft.com2007-01-311-10/+1
|
* Add comments, plus fix zapFragileInfo to zap worker infosimonpj@microsoft.com2006-12-111-2/+7
| | | | | | This is a minor fix up to the patch * retain arity for let-bound vars in simplifier
* retain arity for let-bound vars in simplifierKirsten Chevalier2006-11-281-1/+3
|
* Various debugging print changes; nothing excitingsimonpj@microsoft.com2006-11-061-5/+11
|
* Tidy up substitutionssimonpj@microsoft.com2006-11-061-0/+5
| | | | | | | | | | | | | | The new simplifer stuff exposed the fact that the invariants on the TvSubstEnv and IdSubstEnv were insufficiently explicit. (Resulted in a bug found by Sam Brosnon.) This patch fixes the bug, and tries to document the invariants pretty thoroughly. See Note [Extending the TvSubst] in Type Note [Extenting the Subst] in CoreSubst (Most of the new lines are comments.)
* Major overhaul of the Simplifiersimonpj@microsoft.com2006-11-011-128/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This big patch completely overhauls the Simplifier. The simplifier had grown old and crufty, and was hard to understand and maintain. This new version is still quite complicated, because the simplifier does a lot, but it's much easier to understand, for me at least. It does mean that I have touched almost every line of the simplifier, so the diff is a large one. Big changes are these * When simplifying an Expr we generate a simplified Expr plus a bunch of "floats", which are bindings that have floated out of the Expr. Before, this float stuff was returned separately, but not they are embedded in the SimplEnv, which makes the plumbing much easier and more robust. In particular, the SimplEnv already meaintains the "in-scope set", and making that travel with the floats helps to ensure that we always use the right in-scope set. This change has a pervasive effect. * Rather than simplifying the args of a call before trying rules and inlining, we now defer simplifying the args until both rules and inlining have failed, so we're going to leave a call in the result. This avoids the risk of repeatedly simplifying an argument, which was handled by funny ad-hoc flags before. The downside is that we must apply the substitution to the args before rule-matching; and if thep rule doesn't match that is wasted work. But having any rules at all is the exception not the rule, and the substitution is lazy, so we only substitute until a no-match is found. The code is much more elegant though. * A SimplCont is now more zipper-like. It used to have an embedded function, but that was a bit hard to think about, and now it's nice and consistent. The relevant constructors are StrictArg and StrictBind * Each Rule now has an *arity* (gotten by CoreSyn.ruleArity), which tells how many arguments it matches against. This entailed adding a field ru_nargs to a BuiltinRule. And that made me look at PrelRules; I did quite a bit of refactoring in the end, so the diff in PrelRules looks much biggger than it really is. * A little refactoring in OccurAnal. The key change is that in the RHS of x = y `cast` co we regard 'y' as "many", so that it doesn't get inlined into the RHS of x. This allows x to be inlined elsewhere. It's very like the existing situation for x = Just y where we treat 'y' as "many".
* Remove unused OccInfo (simplification)simonpj@microsoft.com2006-10-051-27/+12
| | | | | | | | | | | The substitution used to carry "fragile" OccInfo to call sites via the DoneId constructor of SimplEnv.SimplSR. This was always a tricky thing to do, and for some time I've been removing the need for it. Now at last I think we can nuke it altogether. Hooray. I did a full nonfib run, and got zero perf changes.
* Comments onlysimonpj@microsoft.com2006-10-041-1/+1
|
* Complete the evidence generation for GADTsManuel M T Chakravarty2006-09-201-5/+4
| | | | | | | | | | | | | | | Mon Sep 18 14:43:22 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Complete the evidence generation for GADTs Sat Aug 5 21:39:51 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Complete the evidence generation for GADTs Thu Jul 13 17:18:07 EDT 2006 simonpj@microsoft.com This patch completes FC evidence generation for GADTs. It doesn't work properly yet, because part of the compiler thinks (t1 :=: t2) => t3 is represented with FunTy/PredTy, while the rest thinks it's represented using ForAllTy. Once that's done things should start to work.
* Massive patch for the first months work adding System FC to GHC #30Manuel M T Chakravarty2006-09-151-78/+23
| | | | | | | | | | | Fri Aug 4 18:13:20 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Massive patch for the first months work adding System FC to GHC #30 Broken up massive patch -=chak Original log message: This is (sadly) all done in one patch to avoid Darcs bugs. It's not complete work... more FC stuff to come. A compiler using just this patch will fail dismally.
* Arity and eta-expansion tuningsimonpj@microsoft.com2006-06-211-13/+26
| | | | | | | | | | | | | | | | | | | Roman found that loop :: STRef s a -> Int -> ST s Int loop ref n = case n of 0 -> return n n -> loop ref (n-1) wasn't eta-expanding nicely, despite the 'state hack' (see Id.isStateHackType). The reason was two-fold: a) a bug in CoreUtils.arityType (the Var case) b) the arity of a recursive function was not being exposed in its RHS (see commments with SimplEnv.addLetIdInfo The commit fixes both.
* Make rules available in RHSsimonpj@microsoft.com2006-05-041-1/+1
| | | | | | | | After some earlier re-factoring, the code that was carefully trying to make RULES available in a function's own RHS was plain wrong. This commit fixes it. Some programs should go faster!
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+741
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.