1. 11 Jul, 2000 1 commit
  2. 20 Jun, 2000 1 commit
    • sewardj's avatar
      [project @ 2000-06-20 15:31:33 by sewardj] · 11c9fdd3
      sewardj authored
      Force binds with coreBindsSize after every simplifier iteration.
      Significantly reduces space use, especially with -O.  This could
      probably be done more cleanly.
      11c9fdd3
  3. 18 Jun, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-06-18 08:37:17 by simonpj] · 91ef36b9
      simonpj authored
      *** MERGE WITH 4.07 ***
      
      * Fix the ambiguity check in TcMonotype.lhs so that
        it is not carried out for types read from interface 
        files.  Some workers may get ambiguous types but that
        does not matter, and should not make compilation fail.
        More detail in the comments with TcMonoType.tc_type_kind
        (the HsForAll case)
      
      * Don't create specialisations for type applications 
        where there's a matching rule.  The rule should
        clearly take precedence.  (Bug reported by Sven.)
        I havn't tested this fix.
      
      * Run the occurrence analyser after tidyCore, so that
        occurrence info (notably dead-var info) is correct
        for the code generators.  This should fix Erik's problem,
        but again I've not tested the fix.  The extra call 
        is in Main.lhs
      
      * Fix CoreToStg so that it can handle an StgLam in mkStgCase.
        This only shows up in a wierd case, documented in 
        CoreToStg.mkStgCase
      91ef36b9
  4. 13 Jun, 2000 1 commit
  5. 25 May, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-05-25 12:41:14 by simonpj] · 495ef8bd
      simonpj authored
      ~~~~~~~~~~~~
      		Apr/May 2000
      		~~~~~~~~~~~~
      
      This is a pretty big commit!  It adds stuff I've been working on
      over the last month or so.  DO NOT MERGE IT WITH 4.07!
      
      Interface file formats have changed a little; you'll need
      to make clean before remaking.
      
      						Simon PJ
      
      Recompilation checking
      ~~~~~~~~~~~~~~~~~~~~~~
      Substantial improvement in recompilation checking.  The version management
      is now entirely internal to GHC.  ghc-iface.lprl is dead!
      
      The trick is to generate the new interface file in two steps:
        - first convert Types etc to HsTypes etc, and thereby
      	build a new ParsedIface
        - then compare against the parsed (but not renamed) version of the old
      	interface file
      Doing this meant adding code to convert *to* HsSyn things, and to
      compare HsSyn things for equality.  That is the main tedious bit.
      
      Another improvement is that we now track version info for
      fixities and rules, which was missing before.
      
      
      Interface file reading
      ~~~~~~~~~~~~~~~~~~~~~~
      Make interface files reading more robust.
        * If the old interface file is unreadable, don't fail. [bug fix]
      
        * If the old interface file mentions interfaces
          that are unreadable, don't fail. [bug fix]
      
        * When we can't find the interface file,
          print the directories we are looking in.  [feature]
      
      
      Type signatures
      ~~~~~~~~~~~~~~~
        * New flag -ddump-types to print type signatures
      
      
      Type pruning
      ~~~~~~~~~~~~
      When importing
      	data T = T1 A | T2 B | T3 C
      it seems excessive to import the types A, B, C as well, unless
      the constructors T1, T2 etc are used.  A,B,C might be more types,
      and importing them may mean reading more interfaces, and so on.
       So the idea is that the renamer will just import the decl
      	data T
      unless one of the constructors is used.  This turns out to be quite
      easy to implement.  The downside is that we must make sure the
      constructors are always available if they are really needed, so
      I regard this as an experimental feature.
      
      
      Elimininate ThinAir names
      ~~~~~~~~~~~~~~~~~~~~~~~~~
      Eliminate ThinAir.lhs and all its works.  It was always a hack, and now
      the desugarer carries around an environment I think we can nuke ThinAir
      altogether.
      
      As part of this, I had to move all the Prelude RdrName defns from PrelInfo
      to PrelMods --- so I renamed PrelMods as PrelNames.
      
      I also had to move the builtinRules so that they are injected by the renamer
      (rather than appearing out of the blue in SimplCore).  This is if anything simpler.
      
      Miscellaneous
      ~~~~~~~~~~~~~
      * Tidy up the data types involved in Rules
      
      * Eliminate RnEnv.better_provenance; use Name.hasBetterProv instead
      
      * Add Unique.hasKey :: Uniquable a => a -> Unique -> Bool
        It's useful in a lot of places
      
      * Fix a bug in interface file parsing for __U[!]
      495ef8bd
  6. 24 May, 2000 3 commits
    • simonpj's avatar
      [project @ 2000-05-24 15:47:13 by simonpj] · 95929be0
      simonpj authored
      MERGE 4.07
      
      * This fix cures the weird 'ifaceBinds' error that
        Sven and George tripped over.  It was quite obscure!
      
        Basically, there was a top level binding
      	f = x
        lying around, which CoreToStg didn't like.  Why hadn't
        it been substituted away?  Because it had a NOINLINE
        pragma.  Why did it have a NOINLINE pragma?  Because
        it's an always-diverging function, so we never want to
        inline it.
      95929be0
    • simonpj's avatar
      [project @ 2000-05-24 12:43:20 by simonpj] · 7233046f
      simonpj authored
      Fix unused-import warning --- again!
      7233046f
    • simonpj's avatar
      [project @ 2000-05-24 11:39:48 by simonpj] · 6e04c7e8
      simonpj authored
      MERGE 4.07
      
      * When float outwards (full laziness) remember to
        switch off the demand flag.  Else we wrongly
        can transform
      	\x -> let y __D = (...) in y+x
        into
      	let y __D = (...)
      	in \x -> y+x
        In the latter, y is not necessarily demanded;
        it depends whether the function is called.  We
        should switch off the demand flag.
      
        The fix is right at the bottom in SetLevels.subst_id_info
      6e04c7e8
  7. 23 May, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-05-23 11:35:36 by simonpj] · bb91427f
      simonpj authored
      *** MERGE WITH 4.07 (once I've checked it works) ***
      
      * Fix result type signatures.  Note that a consequential change is that
        an ordinary binding with a variable on the left
      	f = e
        is now treated as a FunMonoBind, not a PatMonoBind.  This makes
        a few things a bit simpler (eg rnMethodBinds)
      
      * Fix warnings for unused imports.  This meant moving where provenances
        are improved in RnNames.  Move mkExportAvails from RnEnv to RnNames.
      
      * Print module names right (small change in Module.lhs and Rename.lhs)
      
      * Remove a few unused bindings
        
      * Add a little hack to let us print info about join points that turn
        out not to be let-no-escaped.  The idea is to call them "$j" and report
        any such variables that are not let-no-escaped.
      
      * Some small things aiming towards -ddump-types (harmless but incomplete)
      bb91427f
  8. 15 May, 2000 1 commit
    • keithw's avatar
      [project @ 2000-05-15 15:34:03 by keithw] · 9df1b97e
      keithw authored
      Adjust treatment of rules in SimplCore to enable a Core pass to alter
      them if necessary.  Use tricks to ensure that the common case (no change)
      is still efficient.
      9df1b97e
  9. 21 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-21 14:40:48 by simonpj] · 0666c3bb
      simonpj authored
      Remove a way to make the simplifier go into an
      infinite loop.   This has been there for some weeks;
      and George's UniForm tickled it.  I'm amazed nothing
      else has done so.  I'll add a test.
      
      The bad case happened when you go
      
      	let xs = 1:xs
      	in
      	foldr k z xs
      
      Then we kept firing the foldr/cons rule.
      
      Solution: we don't attach an unfolding *at all* to
      loop breakers (Simplify.completeBinding)
      0666c3bb
  10. 19 Apr, 2000 2 commits
  11. 13 Apr, 2000 1 commit
    • panne's avatar
      [project @ 2000-04-13 20:41:30 by panne] · f5262d44
      panne authored
      GHC has instance amnesia again, so a bunch of funny
      `import Ppr{Core,Type} ()? had to be added. Sorry,
      but I need a bootstrapping GHC.
      f5262d44
  12. 10 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-10 12:12:27 by simonpj] · 94084171
      simonpj authored
      Make it so that
      
      (A) All modules imported by Prelude are PrelXXX modules,
          not library modules (notably Ix, Monad were culprits).
      
          This lines up with the Hugs story, and is more intuitive.
      
      (B) All things needed implicitly by syntax (e.g. do-notation
          needs Monad) come from PrelXXX modules, even if they aren't
          visible when you say 'import Prelude'.
      
      These changes simplify the story, and fix the 'looking for [boot]
      interface for Ix' problem.
      
      
      This change is not quite complete.  I'm committing it so
      Simon can finish it off.
      94084171
  13. 07 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-07 13:45:46 by simonpj] · cfbedcec
      simonpj authored
      * Fix 'foreign export' and 'foreign export dynamic' so
        that we can export pure (non-IO) functions as well as IO-ish ones
      
        NB: There's a change to PrelIOBase, so you'll
            need to recompile the Prelude
      
      * Add Type.mkDictTys and call it in various places.
      cfbedcec
  14. 05 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-05 16:25:51 by simonpj] · d4e0a55c
      simonpj authored
      * Add new flag -fddump-minimal-imports, which dumps a file
        M.imports that contains the (allegedly) minimal bunch of
        imports that make the system work.
        It's done by Rename.printMinimalImports
      
      * Extend foreign import/export to handle
      	* Booleans
      	* newtypes
        as requested by the FFI team
      
      * Tidy up DsCCall quite a bit
        Remove maybeBoxedPrimTy from TcHsSyn
      d4e0a55c
  15. 30 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-30 16:23:56 by simonpj] · b822aa0e
      simonpj authored
      * Remove the unnecessary CPR parameter to mkUnfolding and friends
      
      * Make sure that even trivial wrappers have a __inline__
        (this was causing lots of 'substWorker' DEBUG messages)
      
      * Nuke demand info when the unfolding is a value
        (see notes with IdInfo.setUnfoldingInfo)
      
      * Add an update-in-place test to the 'interesting context'
        predicate in SimplUtils.
      b822aa0e
  16. 27 Mar, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-03-27 16:22:09 by simonpj] · 783e505e
      simonpj authored
      Fix a bug in import listing in interface files that meant we lost track of
      interface files.  This fixes the problem that led Sven to add lots of
      import PprType() decls.  I've removed them all again!
      783e505e
    • simonpj's avatar
      [project @ 2000-03-27 13:24:12 by simonpj] · a127213c
      simonpj authored
      a) Move Unfolding and UnfoldingGuidance to CoreSyn
         As a result, remove several SOURCE imports
         Shrink CoreSyn.hi-boot considerably
         Delete CoreUnfold.hi-boot altogether
      
      b) Add CoreUtils.exprIsConApp_maybe
         Use in PrelRules to fix a bug in the dataToTag rule
      
      c) Fix boolean polarity error in Simplify.lhs
      a127213c
  17. 25 Mar, 2000 1 commit
    • panne's avatar
      [project @ 2000-03-25 12:38:40 by panne] · cca2c69f
      panne authored
      Adding a bunch of `import PprType ()' to make 4.07 compile itself.
      Strangely enough, compilation with 4.06 worked without these, so
      this is probably only fighting the symptoms of something deeper,
      and somebody should have a look at it. But for now, I simply need
      a bootstrapping 4.07...
      cca2c69f
  18. 24 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-24 17:49:29 by simonpj] · 6c872fff
      simonpj authored
      a) Small wibbles to do with inlining and floating
      
      b) Implement Ralf's request, so that one can write
      
      	type F = forall a. a -> a
      
      	f :: Int -> F
      	f = ...
      
         The for-alls inside F are hoisted out to the top of
         the type signature for f.  This applies uniformly to
         all user-written types
      6c872fff
  19. 23 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-23 17:45:17 by simonpj] · 111cee3f
      simonpj authored
      This utterly gigantic commit is what I've been up to in background
      mode in the last couple of months.  Originally the main goal
      was to get rid of Con (staturated constant applications)
      in the CoreExpr type, but one thing led to another, and I kept
      postponing actually committing.   Sorry.
      
      	Simon, 23 March 2000
      
      
      I've tested it pretty thoroughly, but doubtless things will break.
      
      Here are the highlights
      
      * Con is gone; the CoreExpr type is simpler
      * NoRepLits have gone
      * Better usage info in interface files => less recompilation
      * Result type signatures work
      * CCall primop is tidied up
      * Constant folding now done by Rules
      * Lots of hackery in the simplifier
      * Improvements in CPR and strictness analysis
      
      Many bug fixes including
      
      * Sergey's DoCon compiles OK; no loop in the strictness analyser
      * Volker Wysk's programs don't crash the CPR analyser
      
      I have not done much on measuring compilation times and binary sizes;
      they could have got worse.  I think performance has got significantly
      better, though, in most cases.
      
      
      Removing the Con form of Core expressions
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      The big thing is that
      
        For every constructor C there are now *two* Ids:
      
      	C is the constructor's *wrapper*. It evaluates and unboxes arguments
      	before calling $wC.  It has a perfectly ordinary top-level defn
      	in the module defining the data type.
      
      	$wC is the constructor's *worker*.  It is like a primop that simply
      	allocates and builds the constructor value.  Its arguments are the
      	actual representation arguments of the constructor.
      	Its type may be different to C, because:
      		- useless dict args are dropped
      		- strict args may be flattened
      
        For every primop P there is *one* Id, its (curried) Id
      
        Neither contructor worker Id nor the primop Id have a defminition anywhere.
        Instead they are saturated during the core-to-STG pass, and the code generator
        generates code for them directly. The STG language still has saturated
        primops and constructor applications.
      
      * The Const type disappears, along with Const.lhs.  The literal part
        of Const.lhs reappears as Literal.lhs.  Much tidying up in here,
        to bring all the range checking into this one module.
      
      * I got rid of NoRep literals entirely.  They just seem to be too much trouble.
      
      * Because Con's don't exist any more, the funny C { args } syntax
        disappears from inteface files.
      
      
      Parsing
      ~~~~~~~
      * Result type signatures now work
      	f :: Int -> Int = \x -> x
      	-- The Int->Int is the type of f
      
      	g x y :: Int = x+y
      	-- The Int is the type of the result of (g x y)
      
      
      Recompilation checking and make
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * The .hi file for a modules is not touched if it doesn't change.  (It used to
        be touched regardless, forcing a chain of recompilations.)  The penalty for this
        is that we record exported things just as if they were mentioned in the body of
        the module.  And the penalty for that is that we may recompile a module when
        the only things that have changed are the things it is passing on without using.
        But it seems like a good trade.
      
      * -recomp is on by default
      
      Foreign declarations
      ~~~~~~~~~~~~~~~~~~~~
      * If you say
      	foreign export zoo :: Int -> IO Int
        then you get a C produre called 'zoo', not 'zzoo' as before.
        I've also added a check that complains if you export (or import) a C
        procedure whose name isn't legal C.
      
      
      Code generation and labels
      ~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Now that constructor workers and wrappers have distinct names, there's
        no need to have a Foo_static_closure and a Foo_closure for constructor Foo.
        I nuked the entire StaticClosure story.  This has effects in some of
        the RTS headers (i.e. s/static_closure/closure/g)
      
      
      Rules, constant folding
      ~~~~~~~~~~~~~~~~~~~~~~~
      * Constant folding becomes just another rewrite rule, attached to the Id for the
        PrimOp.   To achieve this, there's a new form of Rule, a BuiltinRule (see CoreSyn.lhs).
        The prelude rules are in prelude/PrelRules.lhs, while simplCore/ConFold.lhs has gone.
      
      * Appending of constant strings now works, using fold/build fusion, plus
        the rewrite rule
      	unpack "foo" c (unpack "baz" c n)  =  unpack "foobaz" c n
        Implemented in PrelRules.lhs
      
      * The CCall primop is tidied up quite a bit.  There is now a data type CCall,
        defined in PrimOp, that packages up the info needed for a particular CCall.
        There is a new Id for each new ccall, with an big "occurrence name"
      	{__ccall "foo" gc Int# -> Int#}
        In interface files, this is parsed as a single Id, which is what it is, really.
      
      Miscellaneous
      ~~~~~~~~~~~~~
      * There were numerous places where the host compiler's
        minInt/maxInt was being used as the target machine's minInt/maxInt.
        I nuked all of these; everything is localised to inIntRange and inWordRange,
        in Literal.lhs
      
      * Desugaring record updates was broken: it didn't generate correct matches when
        used withe records with fancy unboxing etc.  It now uses matchWrapper.
      
      * Significant tidying up in codeGen/SMRep.lhs
      
      * Add __word, __word64, __int64 terminals to signal the obvious types
        in interface files.  Add the ability to print word values in hex into
        C code.
      
      * PrimOp.lhs is no longer part of a loop.  Remove PrimOp.hi-boot*
      
      
      Types
      ~~~~~
      * isProductTyCon no longer returns False for recursive products, nor
        for unboxed products; you have to test for these separately.
        There's no reason not to do CPR for recursive product types, for example.
        Ditto splitProductType_maybe.
      
      Simplification
      ~~~~~~~~~~~~~~~
      * New -fno-case-of-case flag for the simplifier.  We use this in the first run
        of the simplifier, where it helps to stop messing up expressions that
        the (subsequent) full laziness pass would otherwise find float out.
        It's much more effective than previous half-baked hacks in inlining.
      
        Actually, it turned out that there were three places in Simplify.lhs that
        needed to know use this flag.
      
      * Make the float-in pass push duplicatable bindings into the branches of
        a case expression, in the hope that we never have to allocate them.
        (see FloatIn.sepBindsByDropPoint)
      
      * Arrange that top-level bottoming Ids get a NOINLINE pragma
        This reduced gratuitous inlining of error messages.
        But arrange that such things still get w/w'd.
      
      * Arrange that a strict argument position is regarded as an 'interesting'
        context, so that if we see
      	foldr k z (g x)
        then we'll be inclined to inline g; this can expose a build.
      
      * There was a missing case in CoreUtils.exprEtaExpandArity that meant
        we were missing some obvious cases for eta expansion
        Also improve the code when handling applications.
      
      * Make record selectors (identifiable by their IdFlavour) into "cheap" operations.
      	  [The change is a 2-liner in CoreUtils.exprIsCheap]
        This means that record selection may be inlined into function bodies, which
        greatly improves the arities of overloaded functions.
      
      * Make a cleaner job of inlining "lone variables".  There was some distributed
        cunning, but I've centralised it all now in SimplUtils.analyseCont, which
        analyses the context of a call to decide whether it is "interesting".
      
      * Don't specialise very small functions in Specialise.specDefn
        It's better to inline it.  Rather like the worker/wrapper case.
      
      * Be just a little more aggressive when floating out of let rhss.
        See comments with Simplify.wantToExpose
        A small change with an occasional big effect.
      
      * Make the inline-size computation think that
      	case x of I# x -> ...
        is *free*.
      
      
      CPR analysis
      ~~~~~~~~~~~~
      * Fix what was essentially a bug in CPR analysis.  Consider
      
      	letrec f x = let g y = let ... in f e1
      		     in
      		     if ... then (a,b) else g x
      
        g has the CPR property if f does; so when generating the final annotated
        RHS for f, we must use an envt in which f is bound to its final abstract
        value.  This wasn't happening.  Instead, f was given the CPR tag but g
        wasn't; but of course the w/w pass gives rotten results in that case!!
        (Because f's CPR-ness relied on g's.)
      
        On they way I tidied up the code in CprAnalyse.  It's quite a bit shorter.
      
        The fact that some data constructors return a constructed product shows
        up in their CPR info (MkId.mkDataConId) not in CprAnalyse.lhs
      
      
      
      Strictness analysis and worker/wrapper
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * BIG THING: pass in the demand to StrictAnal.saExpr.  This affects situations
        like
      	f (let x = e1 in (x,x))
        where f turns out to have strictness u(SS), say.  In this case we can
        mark x as demanded, and use a case expression for it.
      
        The situation before is that we didn't "know" that there is the u(SS)
        demand on the argument, so we simply computed that the body of the let
        expression is lazy in x, and marked x as lazily-demanded.  Then even after
        f was w/w'd we got
      
      	let x = e1 in case (x,x) of (a,b) -> $wf a b
      
        and hence
      
      	let x = e1 in $wf a b
      
        I found a much more complicated situation in spectral/sphere/Main.shade,
        which improved quite a bit with this change.
      
      * Moved the StrictnessInfo type from IdInfo to Demand.  It's the logical
        place for it, and helps avoid module loops
      
      * Do worker/wrapper for coerces even if the arity is zero.  Thus:
      	stdout = coerce Handle (..blurg..)
        ==>
      	wibble = (...blurg...)
      	stdout = coerce Handle wibble
        This is good because I found places where we were saying
      	case coerce t stdout of { MVar a ->
      	...
      	case coerce t stdout of { MVar b ->
      	...
        and the redundant case wasn't getting eliminated because of the coerce.
      111cee3f
  20. 06 Jan, 2000 1 commit
  21. 04 Jan, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-01-04 17:40:46 by simonpj] · 5ca77490
      simonpj authored
      This commit arranges that literal strings will fuse
      nicely, by expressing them as an application of build.
      
      * NoRepStr is now completely redundant, though I havn't removed it yet.
      
      * The unpackStr stuff moves from PrelPack to PrelBase.
      
      * There's a new form of Rule, a BuiltinRule, for rules that
        can't be expressed in Haskell.  The string-fusion rule is one
        such.  It's defined in prelude/PrelRules.lhs.
      
      * PrelRules.lhs also contains a great deal of code that
        implements constant folding.  In due course this will replace
        ConFold.lhs, but for the moment it simply duplicates it.
      5ca77490
  22. 13 Dec, 1999 1 commit
  23. 07 Dec, 1999 1 commit
  24. 02 Dec, 1999 1 commit
    • simonmar's avatar
      [project @ 1999-12-02 13:33:06 by simonmar] · 68f77b1b
      simonmar authored
      The infamous "NOTE: simplifier still going..." message is now
      protected by #ifdef DEBUG.  It doesn't mean much to the average user,
      and we tend to use DEBUG when hacking anyway.
      68f77b1b
  25. 01 Nov, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-11-01 17:09:54 by simonpj] · 30b5ebe4
      simonpj authored
      A regrettably-gigantic commit that puts in place what Simon PJ
      has been up to for the last month or so, on and off.
      
      The basic idea was to restore unfoldings to *occurrences* of
      variables without introducing a space leak.  I wanted to make
      sure things improved relative to 4.04, and that proved depressingly
      hard.  On the way I discovered several quite serious bugs in the
      simplifier.
      
      Here's a summary of what's gone on.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * No commas between for-alls in RULES.  This makes the for-alls have
        the same syntax as in types.
      
      * Arrange that simplConArgs works in one less pass than before.
        This exposed a bug: a bogus call to completeBeta.
      
      * Add a top-level flag in CoreUnfolding, used in callSiteInline
      
      * Extend w/w to use etaExpandArity, so it does eta/coerce expansion
      
      * Implement inline phases.   The meaning of the inline pragmas is
        described in CoreUnfold.lhs.  You can say things like
      	{#- INLINE 2 build #-}
        to mean "inline build in phase 2"
      
      * Don't float anything out of an INLINE.
        Don't float things to top level unless they also escape a value lambda.
      	[see comments with SetLevels.lvlMFE
        Without at least one of these changes, I found that
      	{-# INLINE concat #-}
      	concat = __inline (/\a -> foldr (++) [])
        was getting floated to
      	concat = __inline( /\a -> lvl a )
      	lvl = ...inlined version of foldr...
      
        Subsequently I found that not floating constants out of an INLINE
        gave really bad code like
      	__inline (let x = e in \y -> ...)
        so I now let things float out of INLINE
      
      * Implement the "reverse-mapping" idea for CSE; actually it turned out to be easier
        to implement it in SetLevels, and may benefit full laziness too.
      
      * It's a good idea to inline inRange. Consider
      
      	index (l,h) i = case inRange (l,h) i of
      		  	  True ->  l+i
      			  False -> error
        inRange itself isn't strict in h, but if it't inlined then 'index'
        *does* become strict in h.  Interesting!
      
      * Big change to the way unfoldings and occurrence info is propagated in the simplifier
        The plan is described in Subst.lhs with the Subst type
        Occurrence info is now in a separate IdInfo field than user pragmas
      
      * I found that
      	(coerce T (coerce S (\x.e))) y
        didn't simplify in one round. First we get to
      	(\x.e) y
        and only then do the beta. Solution: cancel the coerces in the continuation
      
      * Amazingly, CoreUnfold wasn't counting the cost of a function an application.
      
      * Disable rules in initial simplifier run.  Otherwise full laziness
        doesn't get a chance to lift out a MFE before a rule (e.g. fusion)
        zaps it.  queens is a case in point
      
      * Improve float-out stuff significantly.  The big change is that if we have
      
      	\x -> ... /\a -> ...let p = ..a.. in let q = ...p...
      
        where p's rhs doesn't x, we abstract a from p, so that we can get p past x.
        (We did that before.)  But we also substitute (p a) for p in q, and then
        we can do the same thing for q.  (We didn't do that, so q got stuck.)
        This is much better.  It involves doing a substitution "as we go" in SetLevels,
        though.
      30b5ebe4
  26. 17 Sep, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-09-17 09:15:22 by simonpj] · 731f53de
      simonpj authored
      This bunch of commits represents work in progress on inlining and
      worker/wrapper stuff.
      
      Currently, I think it makes the compiler slightly worse than 4.04, for
      reasons I don't yet understand.  But it means that Simon and I can
      both peer at what is going on.
      
      * Substantially improve handling of coerces in worker/wrapper
      
      * exprIsDupable for an application (f e1 .. en) wasn't calling exprIsDupable
        on the arguments!!  So applications with few, but large, args were being dupliated.
      
      * sizeExpr on an application wasn't doing a nukeScrutDiscount on the arg of
        an application!!  So bogus discounts could accumulate from arguments!
      
      * Improve handling of INLINE pragmas in calcUnfoldingGuidance.  It was really
        wrong before
      731f53de
  27. 06 Sep, 1999 1 commit
  28. 31 Aug, 1999 1 commit
  29. 14 Jul, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-07-14 14:40:20 by simonpj] · 4e7d56fd
      simonpj authored
      Main things:
      
      * Add splitProductType_maybe to DataCon.lhs, with type
        splitProductType_maybe
      	:: Type 			-- A product type, perhaps
      	-> Maybe (TyCon, 		-- The type constructor
      		  [Type],		-- Type args of the tycon
      		  DataCon,		-- The data constructor
      		  [Type])		-- Its *representation* arg types
      
        Then use it in many places (e.g. worker-wrapper places) instead
        of a pile of junk
      
      * Clean up various uses of dataConArgTys, which were plain wrong because
        they weren't passed the existential type arguments.  Most of these calls
        are eliminated by using splitProductType_maybe above.  I hope I correctly
        squashed the others. This fixes a bug that Meurig's programs showed up.
      
          module FailGHC (killSustainer) where
          import Weak
          import IOExts
      
          data Sustainer = forall a . Sustainer (IORef (Maybe a)) (IO ())
      
          killSustainer :: Sustainer -> IO ()
          killSustainer (Sustainer _ act) = act
      
        The above program used to kill the compiler.
      
      * A fairly concerted attack on the Dreaded Space Leak.
      	- Add Type.seqType, CoreSyn.seqExpr, CoreSyn.seqRules
      
      	- Add some seq'ing when building Ids and IdInfos
      		These reduce the space usage a lot
      
      	- Add CoreSyn.coreBindsSize, which is pretty strict in the program,
      		and call it when we have -dshow-passes.
      
      	- Do not put the inlining in an Id that is being plugged into
      		the result-expression of the simplifier.  This cures
      		a the 'wedge' in the space profile for reasons I don't understand fully
      
        Together, these things reduce the max space usage when compiling PrelNum from
        17M to about 7Mbytes.
      
        I think there are now *too many* seqs, and they waste work, but I don't have
        time to find which ones.
      
        Furthermore, we aren't done. For some reason, some of the stuff allocated by
        the simplifier makes it through all during code generation and I don't see why.
        There's a should-be-unnecessary call to coreBindsSize in Main.main which
        zaps some, but not all of this space.
      
        -dshow-passes reduces space usage a bit, but I don't think it should really.
      
        All the measurements were made on a compiler compiled with profiling by
        GHC 3.03.    I hope they carry over to other builds!
      
      * One trivial thing: changed all variables 'label' to 'lbl', becuase the
        former is a keyword with -fglagow-exts in GHC 3.03 (which I was compiling with).
        Something similar in StringBuffer.
      4e7d56fd
  30. 06 Jul, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-07-06 16:45:31 by simonpj] · 9d38678e
      simonpj authored
      All Simon's recent tuning changes.  Rough summary follows:
      
      * Fix Kevin Atkinson's cant-find-instance bug.  Turns out that Rename.slurpSourceRefs
        needs to repeatedly call getImportedInstDecls, and then go back to slurping
        source-refs.  Comments with Rename.slurpSourceRefs.
      
      * Add a case to Simplify.mkDupableAlt for the quite-common case where there's
        a very simple alternative, in which case there's no point in creating a
        join-point binding.
      
      * Fix CoreUtils.exprOkForSpeculation so that it returns True of (==# a# b#).
        This lack meant that
      	case ==# a# b# of { True -> x; False -> x }
        was not simplifying
      
      * Make float-out dump bindings at the top of a function argument, as
        at the top of a let(rec) rhs.  See notes with FloatOut.floatRhs
      
      * Make the ArgOf case of mkDupableAlt generate a OneShot lambda.
        This gave a noticeable boost to spectral/boyer2
      
      
      * Reduce the number of coerces, using worker/wrapper stuff.
        The main idea is in WwLib.mkWWcoerce.  The gloss is that we must do
        the w/w split even for small non-recursive things.  See notes with
        WorkWrap.tryWw.
      
      * This further complicated getWorkerId, so I finally bit the bullet and
        make the workerInfo field of the IdInfo work properly, including
        under substitutions.  Death to getWorkerId.  Kevin Glynn will be happy.
      
      * Make all lambdas over realWorldStatePrimTy
        into one-shot lambdas.  This is a GROSS HACK.
      
      * Also make the occurrence analyser aware of one-shot lambdas.
      
      * Make various Prelude things into INLINE, so that foldr doesn't
        get inlined in their body, so that the caller gets the benefit
        of fusion.  Notably in PrelArr.lhs.
      9d38678e
  31. 28 Jun, 1999 3 commits
  32. 25 Jun, 1999 1 commit
  33. 24 Jun, 1999 2 commits