Added a pragma {-# NOVECTORISE f #-} that suppresses vectorisation of toplevel variable 'f'.
Take vectorisation declarations into account during the initial occurrence analysis (right after desugaring).
This BIG PATCH contains most of the work for the New Coercion Representation See the paper "Practical aspects of evidence based compilation in System FC" * Coercion becomes a data type, distinct from Type * Coercions become value-level things, rather than type-level things, (although the value is zero bits wide, like the State token) A consequence is that a coerion abstraction increases the arity by 1 (just like a dictionary abstraction) * There is a new constructor in CoreExpr, namely Coercion, to inject coercions into terms
Fix recursive superclasses (again). Fixes Trac #4809. This patch finally deals with the super-delicate question of superclases in possibly-recursive dictionaries. The key idea is the DFun Superclass Invariant (see TcInstDcls): In the body of a DFun, every superclass argument to the returned dictionary is either * one of the arguments of the DFun, or * constant, bound at top level To establish the invariant, we add new "silent" superclass argument(s) to each dfun, so that the dfun does not do superclass selection internally. There's a bit of hoo-ha to make sure that we don't print those silent arguments in error messages; a knock on effect was a change in interface-file format. A second change is that instead of the complex and fragile "self dictionary binding" in TcInstDcls and TcClassDcl, using the same mechanism for existential pattern bindings. See Note [Subtle interaction of recursion and overlap] in TcInstDcls and Note [Binding when looking up instances] in InstEnv. Main notes are here: * Note [Silent Superclass Arguments] in TcInstDcls, including the DFun Superclass Invariant Main code changes are: * The code for MkId.mkDictFunId and mkDictFunTy * DFunUnfoldings get a little more complicated; their arguments are a new type DFunArg (in CoreSyn) * No "self" argument in tcInstanceMethod * No special tcSimplifySuperClasss * No "dependents" argument to EvDFunApp IMPORTANT It turns out that it's quite tricky to generate the right DFunUnfolding for a specialised dfun, when you use SPECIALISE INSTANCE. For now I've just commented it out (in DsBinds) but that'll lose some optimisation, and I need to get back to this.
Fix a nasty bug in RULE matching: Trac #4814 See Note [Matching lets], which explains it all in detail. It took me a day to think of a nice way to fix the bug, but I think the result is quite respectable. Subtle, though.
Substitution should just substitute, not optimise This was causing Trac #4524, by optimising (e |> co) to e on the LHS of a rule. Result, the template variable 'co' wasn't bound any more. Now that substition doesn't optimise, it seems sensible to call simpleOptExpr rather than substExpr when substituting in the RHS of rules. Not a big deal either way.
Occurrence analyser takes account of the phase when handing RULES See Note [Finding rule RHS free vars] This should make Roman happy.
Do not (ever) use substExprSC in the simplifier "Short-cut" substitution means "do nothing if the substitution is empty". We *never* want do to that in the simplifier because even though the substitution is empty, the in-scope set has useful information: * We get up-to-date unfoldings; and that in turn may reduce the number of iterations of the simplifier * We avoid space leaks, because failing to substitute may hang on to old Ids from a previous iteration (This is what was causing the late inlining of foo in Trac #4428.)
Improve the simple expression optimiser so it does simple beta reduction
Implement INLINABLE pragma Implements Trac #4299. Documentation to come.
Super-monster patch implementing the new typechecker -- at last This major patch implements the new OutsideIn constraint solving algorithm in the typecheker, following our JFP paper "Modular type inference with local assumptions". Done with major help from Dimitrios Vytiniotis and Brent Yorgey.
Robustify the treatement of DFunUnfolding See Note [DFun unfoldings] in CoreSyn. The issue here is that you can't tell how many dictionary arguments a DFun needs just from looking at the Arity of the DFun Id: if the dictionary is represented by a newtype the arity might include the dictionary and value arguments of the (single) method. So we need to record the number of arguments need by the DFun in the DFunUnfolding itself. Details in Note [DFun unfoldings] in CoreSyn
Comments only
Comment out debug warnings; they are fine
A bunch of stuff relating to substitutions on core * I was debugging so I added some call-site info (that touches a lot of code) * I used substExpr a bit less in Simplify, hoping to make the simplifier a little faster and cleaner
Substantial improvements to coercion optimisation The main purpose of this patch is to add a bunch of new rules to the coercion optimiser. They are documented in the (revised) Appendix of the System FC paper. Some code has moved about: - OptCoercion is now a separate module, mainly because it now uses tcMatchTy, which is defined in Unify, so OptCoercion must live higehr up in the hierarchy - Functions that manipulate Kinds has moved from Type.lhs to Coercion.lhs. Reason: the function typeKind now needs to call coercionKind. And in any case, a Kind is a flavour of Type, so it builds on top of Type; indeed Coercions and Kinds are both flavours of Type. This change required fiddling with a number of imports, hence the one-line changes to otherwise-unrelated modules - The representation of CoTyCons in TyCon has changed. Instead of an extensional representation (a kind checker) there is now an intensional representation (namely TyCon.CoTyConDesc). This was needed for one of the new coercion optimisations.
Make warning printing a bit less noisy Use -dppr-debug to make it noisy again
Two improvements to optCoercion * Fix a bug that meant that (right (inst (forall tv.co) ty)) wasn't getting optimised. This showed up in the compiled code for ByteCodeItbls * Add a substitution to optCoercion, so that it simultaneously substitutes and optimises. Both call sites wanted this, and optCoercion itself can use it, so it seems a win all round.
More work on the simplifier's inlining strategies This patch collects a small raft of related changes * Arrange that during (a) rule matching and (b) uses of exprIsConApp_maybe we "look through" unfoldings only if they are active in the phase. Doing this for (a) required a bit of extra plumbing in the rule matching code, but I think it's worth it. One wrinkle is that even if inlining is off (in the 'gentle' phase of simplification) during rule matching we want to "look through" things with inlinings. See SimplUtils.activeUnfInRule. This fixes a long-standing bug, where things that were supposed to be (say) NOINLINE, could still be poked into via exprIsConApp_maybe. * In the above cases, also check for (non-rule) loop breakers; we never look through these. This fixes a bug that could make the simplifier diverge (and did for Roman). Test = simplCore/should_compile/dfun-loop * Try harder not to choose a DFun as a loop breaker. This is just a small adjustment in the OccurAnal scoring function * In the scoring function in OccurAnal, look at the InlineRule unfolding (if there is one) not the actual RHS, beause the former is what'll be inlined. * Make the application of any function to dictionary arguments CONLIKE. Thus (f d1 d2) is CONLIKE. Encapsulated in CoreUtils.isExpandableApp Reason: see Note [Expandable overloadings] in CoreUtils * Make case expressions seem slightly smaller in CoreUnfold. This reverses an unexpected consequences of charging for alternatives. Refactorings ~~~~~~~~~~~~ * Signficantly refactor the data type for Unfolding (again). The result is much nicer. * Add type synonym BasicTypes.CompilerPhase = Int and use it Many of the files touched by this patch are simply knock-on consequences of these two refactorings.
Wibble to substituting InlWrappers See Note [Worker inlining] in CoreSubst