1. 23 Dec, 2015 1 commit
    • Eric Seidel's avatar
      Allow CallStacks to be frozen · 380b25ea
      Eric Seidel authored
      This introduces "freezing," an operation which prevents further
      locations from being appended to a CallStack.  Library authors may want
      to prevent CallStacks from exposing implementation details, as a matter
      of hygiene. For example, in
      
      ```
      head [] = error "head: empty list"
      
      ghci> head []
      *** Exception: head: empty list
      CallStack (from implicit params):
        error, called at ...
      ```
      
      including the call-site of `error` in `head` is not strictly necessary
      as the error message already specifies clearly where the error came
      from.
      
      So we add a function `freezeCallStack` that wraps an existing CallStack,
      preventing further call-sites from being pushed onto it. In other words,
      
      ```
      pushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack
      ```
      
      Now we can define `head` to not produce a CallStack at all
      
      ```
      head [] =
        let ?callStack = freezeCallStack emptyCallStack
        in error "head: empty list"
      
      ghci> head []
      *** Exception: head: empty list
      CallStack (from implici...
      380b25ea
  2. 07 Sep, 2015 2 commits
    • Joachim Breitner's avatar
      Further simplify the story around minimum/maximum · c6b82e99
      Joachim Breitner authored
      After I have found out that I should look at -ddump-prep and not
      -ddump-core, I noticed that these days, GHC is perfectly capeable of
      turning (the equivalent) of foldl to (the equivalent) of foldl' if the
      operation in question is strict. So instead of using rewrite rules to
      rewrite maximum to a strictMaximum for certain types, we simply use
      SPECIALIZE.
      
      This also marks maximum/minimum as INLINEABLE, so that client code can
      get similar specializations, hopefully even automatically. And inded,
      minimum applied to [Double] produces good code (although due to
      inlineing, not due to specialization, it seems).
      
      I checked (by looking at the core) that this still fixes #10788.
      
      Differential revision: https://phabricator.haskell.org/D1229
      c6b82e99
    • Joachim Breitner's avatar
      SPECIALIZE strictMinimum for Int and Integer · dc671a1c
      Joachim Breitner authored
      This fixes a regression reported in #10788, where due to less inlining
      compared to earlier versions, we’d get worse code. With the SPECIALIZE,
      we get the good code, and moreover, the good code is in List.hs and
      _not_ inlined to the use site, so smaller code size and less compilation
      time.
      dc671a1c
  3. 04 Sep, 2015 1 commit
    • Joachim Breitner's avatar
      Make Data.List.foldr1 inline · 85915e9b
      Joachim Breitner authored
      Previously, foldr1 would be defiend recursively and thus not inline.
      This is bad, for example, when maximumBy has a strict comparison
      function: Before the BBP, it was implemented via foldl1, which inlined
      and yielded good code. With BBP, it goes via foldr1, so we better inline
      this as well. Fixes #10830.
      
      Differential Revision: https://phabricator.haskell.org/D1205
      85915e9b
  4. 24 Apr, 2015 1 commit
  5. 23 Jan, 2015 1 commit
  6. 16 Dec, 2014 1 commit
  7. 07 Nov, 2014 1 commit
  8. 02 Nov, 2014 1 commit
  9. 29 Oct, 2014 2 commits
    • David Feuer's avatar
      Really fix fft2 regression. #9740 · 64d0a198
      David Feuer authored
      Rewrite `take` more aggressively for fusion. Add some more explicit
      strictness to `unsafeTake` and `unsafeDrop` that seems to help code size and
      allocation just a drop in some nofib tests. They were not previously
      strict in their numerical arguments, but always called in contexts where
      those had been forced; it didn't make a difference in simple test cases,
      but made a small difference for nofib. See #9740.
      
      Differential Revision: https://phabricator.haskell.org/D394
      64d0a198
    • David Feuer's avatar
      Reorder GHC.List; fix performance regressions · 5f69c8ef
      David Feuer authored
      Rearrange some oddly placed code.
      
      Modify `take` to make the fold unconditionally strict in the passed
      `Int`. This clears up the `fft2` regression.
      This fixes #9740. Differential Revision: https://phabricator.haskell.org/D390
      5f69c8ef
  10. 28 Oct, 2014 2 commits
    • David Feuer's avatar
      base: Refactor/clean-up *List modules · 75979f36
      David Feuer authored
      This gets rid of all hand-unboxing in `GHC.List` and moves `Foldable`
      requirements from `Data.OldList` into `GHC.List` (preparatory work for
      addressing #9716).  Specifically, this moves the definition of
      `maximum`, `minimum`, `foldl'`, `foldl1`, `foldl1'`, `sum`, and
      `product` into `GHC.List` (which now needs to import `GHC.Num`)
      
      Make `take`, `drop`, `length`, and `!!` generally saner (see also #9510)
      
      Performance overall seems minimally affected. Some things go up; some
      things go down; nothing moves horribly much. The code is much easier to
      read.
      
      Differential Revision: https://phabricator.haskell.org/D380
      75979f36
    • Joachim Breitner's avatar
      Make iterateFB inlineable · 98ed815f
      Joachim Breitner authored
      When investigating a case of unexpected Call Arity failure I noticed
      that iterateFB would not inline as far as desired, as it is recursive.
      
      This patch makes it non-recursive (with a local go), which seem so do
      great good.
      98ed815f
  11. 21 Oct, 2014 1 commit
  12. 08 Oct, 2014 1 commit
  13. 07 Oct, 2014 1 commit
    • David Feuer's avatar
      Make scanl fuse; add scanl' · d45693a5
      David Feuer authored
      Summary:
      Make scanl a good producer and a good consumer for fold/build
      fusion. Add strictly-accumulating scanl', which is required for
      Data.List.inits.
      
      Reviewers: nomeata, austin
      
      Reviewed By: austin
      
      Subscribers: spacekitteh, thomie, carter, ezyang, simonmar
      
      Differential Revision: https://phabricator.haskell.org/D314
      
      GHC Trac Issues: #9356
      d45693a5
  14. 01 Oct, 2014 2 commits
  15. 24 Sep, 2014 1 commit
  16. 12 Sep, 2014 1 commit
  17. 04 Sep, 2014 2 commits
  18. 28 Aug, 2014 1 commit
  19. 22 Jul, 2014 1 commit
    • Joachim Breitner's avatar
      Make last a good consumer · b709f0a0
      Joachim Breitner authored
      Summary:
      Make last a good consumer simply by implementing it as foldl. This fixes Trac: #9339.
      Thanks to David Feuer for bringing it up.
      
      Test Plan: perf/should_run/T9339 + general validation
      
      Reviewers: austin
      
      Reviewed By: austin
      
      Subscribers: phaskell, simonmar, relrod, carter
      
      Differential Revision: https://phabricator.haskell.org/D86
      
      Trac Issues: #9339
      b709f0a0
  20. 10 Feb, 2014 1 commit
    • Joachim Breitner's avatar
      Implement foldl with foldr · 78221667
      Joachim Breitner authored
      together with the call arity analysis and the following patch (about inlining
      maximum), we get nice benefits from fusing foldl and foldl' with good
      producers:
      
                      Min          -0.1%    -74.5%     -6.8%     -8.3%    -50.0%
                      Max          +0.2%      0.0%    +38.5%    +38.5%      0.0%
           Geometric Mean          -0.0%     -4.1%     +7.7%     +7.7%     -0.8%
      
      Because this depends on a compiler optimisation, we have to watch out for cases
      where this is not an improvements, and whether they occur in the wild.
      78221667
  21. 28 Jan, 2014 1 commit
    • Joachim Breitner's avatar
      go-ify foldr2 · 81b6befa
      Joachim Breitner authored
      This helps with the changes in #7994, but might also generally be a good
      idea (ignore the runtime):
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs   Runtime   Elapsed  TotalMem
                 fft2          -0.1%     -1.5%      0.07      0.07     +0.0%
             fibheaps          +0.0%    -17.2%      0.03      0.03     +0.0%
                fluid          +0.5%     -0.7%      0.01      0.01     +0.0%
            integrate          +0.0%     -0.9%      0.16      0.16     +0.0%
              rewrite          +0.0%     -1.1%      0.02      0.02     +0.0%
      --------------------------------------------------------------------------------
                  Min          -0.1%    -17.2%     -1.6%     +0.0%     +0.0%
                  Max          +0.5%     +0.0%   +107.7%   +106.2%    +11.3%
       Geometric Mean          +0.0%     -0.2%    +23.7%    +23.9%     +0.1%
      81b6befa
  22. 22 Sep, 2013 1 commit
  23. 18 Sep, 2013 2 commits
  24. 14 Feb, 2013 1 commit
  25. 17 Nov, 2012 1 commit
  26. 27 Oct, 2012 1 commit
  27. 25 Jul, 2012 1 commit
  28. 26 Jun, 2011 1 commit
  29. 18 Jun, 2011 1 commit
  30. 28 Jan, 2011 1 commit
  31. 14 Jul, 2010 1 commit
  32. 21 Feb, 2010 1 commit
  33. 26 Nov, 2009 1 commit
  34. 25 Nov, 2009 1 commit
    • rl@cse.unsw.edu.au's avatar
      Make sure zipWithFB has arity 2 · 450bac65
      rl@cse.unsw.edu.au authored
      It gets 2 arguments in the "zipWith" rule but its arity was higher and the new
      inliner didn't inline it sometimes, for instance here:
      
      mpp ::  [Double] -> [Double] -> [Double] -> [Double] -> [Double]
      mpp as bs cs ds = zipWith (*) (zipWith (+) as bs) (zipWith (+) cs ds)
       
      This was a regression vs. 6.10.
      450bac65