1. 01 May, 2007 1 commit
  2. 09 Feb, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Refactor the simplifier's treatment of case expressions · e9f23b4c
      simonpj@microsoft.com authored
      (NB: this patch could conceivably require some bits of the 
      following SpecConstr patch to compile cleanly.  It's conceptually
      independent, but I'm not 100% certain that I've included all
      the necessary bits here.)
      
      This patch cleans up the simplifier's handling of various
      otimisations for case expressions, notably
        - case elimination (discarding the case altogether)
        - merging identical alternatives
        - discarding impossible alternative
        - merging nested cases
      
      Previously this was partly handled before, and partly after,
      simplifying the case alternatives. The trouble with that is
      that the dead-ness information on the case binders gets munged
      during simplification, and that turned out to mean that 
      case elmination essentially never happened -- stupid.
      
      Now I've moved it all to before simplifying the alterntives.
      In fact this reduces the amount of code, I think, and it's
      certainly tidier.  I don't think there is any loss.
      
      e9f23b4c
  3. 05 Feb, 2007 2 commits
  4. 31 Jan, 2007 1 commit
  5. 11 Jan, 2007 3 commits
  6. 10 Jan, 2007 1 commit
  7. 11 Jan, 2007 1 commit
  8. 03 Jan, 2007 1 commit
  9. 29 Nov, 2006 1 commit
    • andy@galois.com's avatar
      TickBox representation change · 8100cd43
      andy@galois.com authored
      This changes the internal representation of TickBoxes,
      from
              Note (TickBox "module" n)  <expr>
      into
      
              case tick<module,n> of
                _ -> <expr>
      
      tick has type :: #State #World, when the module and tick numbe
      are stored inside IdInfo.
      
      Binary tick boxes change from
      
               Note (BinaryTickBox "module" t f) <expr>
      
      into
      
                btick<module,t,f> <expr>
      
      btick has type :: Bool -> Bool, with the module and tick number
      stored inside IdInfo.
      8100cd43
  10. 10 Nov, 2006 1 commit
  11. 06 Nov, 2006 1 commit
  12. 01 Nov, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Major overhaul of the Simplifier · 7a327c12
      simonpj@microsoft.com authored
      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".
      7a327c12
  13. 24 Oct, 2006 1 commit
    • andy@galois.com's avatar
      Haskell Program Coverage · d5934bbb
      andy@galois.com authored
      This large checkin is the new ghc version of Haskell
      Program Coverage, an expression-level coverage tool for Haskell.
      
      Parts:
      
       - Hpc.[ch] - small runtime support for Hpc; reading/writing *.tix files.
       - Coverage.lhs - Annotates the HsSyn with coverage tickboxes.
        - New Note's in Core,
            - TickBox      -- ticked on entry to sub-expression
            - BinaryTickBox  -- ticked on exit to sub-expression, depending
      	       	     -- on the boolean result.
      
        - New Stg level TickBox (no BinaryTickBoxes, though) 
      
      You can run the coverage tool with -fhpc at compile time. 
      Main must be compiled with -fhpc. 
      				      
      d5934bbb
  14. 16 Oct, 2006 1 commit
  15. 06 Oct, 2006 1 commit
  16. 05 Oct, 2006 5 commits
  17. 04 Oct, 2006 2 commits
    • simonpj@microsoft.com's avatar
      Second bite at the rules-only idea · a35f75aa
      simonpj@microsoft.com authored
      This is part 2 of the patch that improved the interaction of RULES and
      recursion.  It's vital that all Ids that may be referred to from later in
      the module are marked 'IAmALoopBreaker' because otherwise we may do
      postInlineUnconditionally, and lose the binding altogether. 
      
      So I've added a boolean rules-only flag to IAmALoopBreaker.  Now we can
      do inlining for rules-only loop-breakers. 
      a35f75aa
    • simonpj@microsoft.com's avatar
      Eliminate case-of-cast · 0477b389
      simonpj@microsoft.com authored
      Note [Case of cast]
      ~~~~~~~~~~~~~~~~~~~
      Consider 	case (v `cast` co) of x { I# ->
      		... (case (v `cast` co) of {...}) ...
      We'd like to eliminate the inner case.  We can get this neatly by 
      arranging that inside the outer case we add the unfolding
      	v |-> x `cast` (sym co)
      to v.  Then we should inline v at the inner case, cancel the casts, 
      and away we go
      	
      This patch does the job, fixing a performance hole reported by Roman.
      0477b389
  18. 03 Oct, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Make recursion and RULES interact better · c248518f
      simonpj@microsoft.com authored
      See Trac #683
      
      This patch improves the interaction of recursion and RULES; at least I
      hope it does.   The problem was that a RULE was being treated uniformly like
      an "extra RHS". This worked badly when you have a non-recursive definition
      that is made recursive only by RULE.
      
      This patch maeks the occurrence analyser know whether a binder is referred to
      only from RULES (the RulesOnly constructor in OccInfo).  Then we can ignore
      such edges when deciding on the order of bindings in a letrec, and when
      setting the LoopBreaker flag.
      
      The remaining potential problem is this:
      	rec{ f = ...g...
      	   ; g = ...f...
      	     RULE g True = ...
      	   }
      
      The RULE for g may not be visible in f's rhs.  This is fixable, but not
      today.
      
      c248518f
  19. 23 Sep, 2006 1 commit
  20. 20 Sep, 2006 5 commits
    • chak@cse.unsw.edu.au.'s avatar
      Fix problem with selectors for GADT records with unboxed fields · 29e736b7
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:13:11 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Fix problem with selectors for GADT records with unboxed fields
        Sun Aug  6 20:47:11 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Fix problem with selectors for GADT records with unboxed fields
          Wed Aug  2 05:37:38 EDT 2006  kevind@bu.edu
      29e736b7
    • chak@cse.unsw.edu.au.'s avatar
      fix default case filling-in for GADTs · 8912a05e
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:04:19 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fix default case filling-in for GADTs
        Sun Aug  6 20:09:06 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fix default case filling-in for GADTs
          Fri Jul 28 13:19:40 EDT 2006  kevind@bu.edu
      8912a05e
    • chak@cse.unsw.edu.au.'s avatar
      fix big-lambda eta expansion, add comments · 8c9cfd75
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:02:49 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fix big-lambda eta expansion, add comments
        Sun Aug  6 20:07:36 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fix big-lambda eta expansion, add comments
          Fri Jul 28 13:16:51 EDT 2006  kevind@bu.edu
      8c9cfd75
    • chak@cse.unsw.edu.au.'s avatar
      fix some coercion kind representation things, extend exprIsConApp_maybe to non-vanilla · 6fcf9006
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:51:33 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fix some coercion kind representation things, extend exprIsConApp_maybe to non-vanilla
        Sat Aug  5 21:48:21 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fix some coercion kind representation things, extend exprIsConApp_maybe to non-vanilla
          Wed Jul 19 08:06:28 EDT 2006  kevind@bu.edu
      6fcf9006
    • chak@cse.unsw.edu.au.'s avatar
      newtype fixes, coercions for non-recursive newtypes now optional · c94408e5
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:24:27 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * newtype fixes, coercions for non-recursive newtypes now optional
        Sat Aug  5 21:19:58 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * newtype fixes, coercions for non-recursive newtypes now optional
          Fri Jul  7 06:11:48 EDT 2006  kevind@bu.edu
      c94408e5
  21. 19 Sep, 2006 1 commit
  22. 18 Sep, 2006 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      fix out-of-scope variable · 99cf312c
      chak@cse.unsw.edu.au. authored
      Sun Aug  6 20:09:58 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fix out-of-scope variable
        Fri Jul 28 13:40:36 EDT 2006  kevind@bu.edu
      99cf312c
  23. 15 Sep, 2006 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Massive patch for the first months work adding System FC to GHC #30 · bb394e57
      chak@cse.unsw.edu.au. authored
      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.
      bb394e57
  24. 09 Aug, 2006 1 commit
  25. 16 Aug, 2006 4 commits
    • simonpj@microsoft.com's avatar
      Get dead-ness right in knownCon · c55001c5
      simonpj@microsoft.com authored
      c55001c5
    • simonpj@microsoft.com's avatar
      Re-factor mkAtomicArgs and completeNonRecX · ad0cc1df
      simonpj@microsoft.com authored
      This refactoring ensures that when mkAtomicArgs adds new bindings,
      it does so using completeNonRecX, which adds unfoldings etc.  More
      modular, and saves passes too.
      
      (This was important when getting rules to work right.  We want tob
      fire a rule as soon as possible, taking into account all inlinings,
      else a less-good rule applies.  That's what I found when doing 
      stream fusion anyway.)
      
      Regardless, this is an improvement.
      ad0cc1df
    • simonpj@microsoft.com's avatar
      Another try at the continuation-swapping stuff · 0e98e80c
      simonpj@microsoft.com authored
      I have spent altogether too long on my attempt to avoid case-of-case
      in situations where it is a Bad Thing.  All the action is in the
      case for mkDupableAlt that handles cases with a single alternative.
      
      I've added rather extensive comments, and it finally seems to be working
      more or less right.  If you compile (say) GHC/Real.o you'll see quite a
      few case-of-cases remain (which didn't happen before), and they mostly look
      pretty sensible to me.
      0e98e80c
    • simonpj@microsoft.com's avatar
      Don't build unnecessary lets in knownCon · eba4dfc2
      simonpj@microsoft.com authored
      Faced with
      	case x of y { (a,b) -> rhs }
      
      where x is bound to (c,d), we were generating
      	
      	let y = (c,d) in rhs
      
      and thenn hoping to get rid of the y binding by CSE or some such.  It's
      better simply not to build it in the first place, by generating
      
      	let y = x in rhs
      
      This patch does the job.
      eba4dfc2