1. 06 Dec, 2018 1 commit
    • Tobias Decking's avatar
      Add fusion rules for the zipWith functions in base (#15263) · fb669f51
      Tobias Decking authored
      This patch will allow `zip3` and `zipWith3` in `GHC.List` as well
      as `zipWith4`, `zipWith5`, `zipWith6` and `zipWith7` in `Data.OldList` to fuse.
      These rules are kept in a similar style as the rules for `zip` and `zipWith`.
      Added a corresponding test case.
      Test Plan: validate
      Reviewers: hvr, bgamari, simonpj
      Reviewed By: simonpj
      Subscribers: simonpj, rockbmb, rwbarton, carter
      GHC Trac Issues: #15263
      Differential Revision: https://phabricator.haskell.org/D5241
  2. 06 Aug, 2018 1 commit
    • Simon Jakobi's avatar
      Unhide GHC.List for haddock · 672f1773
      Simon Jakobi authored
      The unhidden module GHC.OldList recommends using GHC.List instead.
      In consequence we should also have haddocks for GHC.List.
      (cherry picked from commit e3df129c8bf4c35693d01ea66238882f3e3b6fe1)
  3. 12 Jul, 2018 1 commit
  4. 29 May, 2018 1 commit
  5. 19 Sep, 2017 1 commit
  6. 25 Aug, 2017 1 commit
  7. 19 Aug, 2017 2 commits
  8. 29 Apr, 2017 1 commit
  9. 10 Mar, 2017 1 commit
  10. 10 Jan, 2017 1 commit
    • takano-akio's avatar
      Mark *FB functions INLINE[0] (Fixes #13001) · 09bce7ac
      takano-akio authored
      When fusion rules successfully fire, we are left with calls to
      *FB functions. They are higher-order functions, and therefore they
      often benefit from inlining. This is particularly important when
      then final consumer is a strict fold (foldl', length, etc.), because
      not inlining these functions means allocating a function closure
      for each element in the list, which often is more costly than what
      fusion eliminates.
      Nofib shows a slight increase in the binary size:
             Program           Size    Allocs   Runtime   Elapsed  TotalMem
         gen_regexps          -0.3%      0.0%     0.000     0.000      0.0%
              puzzle          +0.8%      0.0%     0.089     0.090      0.0%
             reptile          +0.8%     -0.0%     0.008     0.008      0.0%
                 Min          -0.3%     -0.0%     -7.3%     -7.1%      0.0%
                 Max          +0.8%     +0.0%     +7.8%     +7.7%     +1.8%
      Geometric Mean          +0.0%     -0.0%     +0.2%     +0.2%     +0.0%
      Reviewers: simonpj, austin, hvr, bgamari
      Reviewed By: simonpj
      Subscribers: simonpj, thomie
      Differential Revision: https://phabricator.haskell.org/D2951
      GHC Trac Issues: #13001
  11. 24 Sep, 2016 1 commit
    • Joachim Breitner's avatar
      Replace INLINEABLE by INLINABLE (#12613) · 68f72f10
      Joachim Breitner authored
      as the latter is the official, correct spelling, and the former just a
      misspelling accepted by GHC.
      Also document in the user’s guide that the alternative spelling is
      This commit was brough to you by HIW 2016.
  12. 08 Apr, 2016 1 commit
  13. 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
      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 implicit params):
        error, called at ...
      1. We add the `freezeCallStack` and `emptyCallStack` and update the
         definition of `CallStack` to support this functionality.
      2. We add `errorWithoutStackTrace`, a variant of `error` that does not
         produce a stack trace, using this feature. I think this is a sensible
         wrapper function to provide in case users want it.
      3. We replace uses of `error` in base with `errorWithoutStackTrace`. The
         rationale is that base does not export any functions that use CallStacks
         (except for `error` and `undefined`) so there's no way for the stack
         traces (from Implicit CallStacks) to include user-defined functions.
         They'll only contain the call to `error` itself. As base already has a
         good habit of providing useful error messages that name the triggering
         function, the stack trace really just adds noise to the error. (I don't
         have a strong opinion on whether we should include this third commit,
         but the change was very mechanical so I thought I'd include it anyway in
         case there's interest)
      4. Updates tests in `array` and `stm` submodules
      Test Plan: ./validate, new test is T11049
      Reviewers: simonpj, nomeata, goldfire, austin, hvr, bgamari
      Reviewed By: simonpj
      Subscribers: thomie
      Projects: #ghc
      Differential Revision: https://phabricator.haskell.org/D1628
      GHC Trac Issues: #11049
  14. 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
      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
    • 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
  15. 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
  16. 24 Apr, 2015 1 commit
  17. 23 Jan, 2015 1 commit
  18. 16 Dec, 2014 1 commit
  19. 07 Nov, 2014 1 commit
  20. 02 Nov, 2014 1 commit
  21. 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
    • 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
  22. 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
      Differential Revision: https://phabricator.haskell.org/D380
    • 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.
  23. 21 Oct, 2014 1 commit
  24. 08 Oct, 2014 1 commit
  25. 07 Oct, 2014 1 commit
    • David Feuer's avatar
      Make scanl fuse; add scanl' · d45693a5
      David Feuer authored
      Make scanl a good producer and a good consumer for fold/build
      fusion. Add strictly-accumulating scanl', which is required for
      Reviewers: nomeata, austin
      Reviewed By: austin
      Subscribers: spacekitteh, thomie, carter, ezyang, simonmar
      Differential Revision: https://phabricator.haskell.org/D314
      GHC Trac Issues: #9356
  26. 01 Oct, 2014 2 commits
  27. 24 Sep, 2014 1 commit
  28. 12 Sep, 2014 1 commit
  29. 04 Sep, 2014 2 commits
  30. 28 Aug, 2014 1 commit
  31. 22 Jul, 2014 1 commit
    • Joachim Breitner's avatar
      Make last a good consumer · b709f0a0
      Joachim Breitner authored
      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
  32. 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
                      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.
  33. 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%
  34. 22 Sep, 2013 1 commit