1. 12 Dec, 2018 1 commit
    • Simon Peyton Jones's avatar
      Improvements to demand analysis · d77501cd
      Simon Peyton Jones authored
      This patch collects a few improvements triggered by Trac #15696,
      and fixing Trac #16029
      * Stop making toCleanDmd behave specially for unlifted types.
        This special case was the cause of stupid behaviour in Trac
        #16029.  And to my joy I discovered the let/app invariant
        rendered it unnecessary.  (Maybe the special case pre-dated
        the let/app invariant.)
        Result: less special-case handling in the compiler, and
        better perf for the compiled code.
      * In WwLib.mkWWstr_one, treat seqDmd like U(AAA).  It was not
        being so treated before, which again led to stupid code.
      * Update and improve Notes
      There are .stderr test wibbles because we get slightly different
      strictness signatures for an argumment of unlifted type:
          <L,U> rather than <S,U>        for Int#
          <S,U> rather than <S(S),U(U)>  for Int
  2. 22 Nov, 2018 1 commit
  3. 28 Oct, 2018 2 commits
    • Christiaan Baaij's avatar
      Comment out CONSTANT_FOLDED in GHC.Natural · 2f2308e2
      Christiaan Baaij authored
      Although these functions were marked as CONSTANT_FOLDED, they did
      not have a corresponding builtinRule in PrelRules. The idea was
      probably to add them eventually, but this hasn't manifested so
      The plan is to eventually add builtin rules for these functions
      over Natural, so as a reminder we simply comment out the
      CONSTANT_FOLDED  annotation instead of removing it completely.
      Reviewers: hvr, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, carter
      Differential Revision: https://phabricator.haskell.org/D5267
    • Fangyi Zhou's avatar
      Fix integer overflow when encoding doubles (Trac #15271) · 8e1a5593
      Fangyi Zhou authored
      Ticket #15271 reports a case where 1e1000000000 is incorrectly
      converted to 0.0. After some investigation, I discovered the number is
      converted to rational correctly, but converting the ratio into a double
      introduced an error.
      Tracking down to how the conversion is done, I found the rts float
      implementation uses `ldexp`, whose signature is
      `double ldexp (double x, int exp);`
      The callsite passes an `I_` to the second argument, which is
      platform-dependent. On machines where `I_` is 64 bits and `int` is 32 bits, we
      observe integer overflow behaviour.
      Here is a mapping from rational to exponent with observations
      1e646457008  -> 2147483645 (result = infinity, positive in int32)
      1e646457009  -> 2147483648 (result = 0.0, overflow to negative in int32)
      1e1000000000 -> 3321928042 (result = infinity, overflow to positive in int32)
      1e1555550000 -> 5167425196 (result = 0.0, overflow to negative in int32)
      We fix this issue by comparing STG_INT_MIN/MAX and INT_MIN/MAX and bound the
      value appropriately.
      Test Plan: New test cases
      Reviewers: bgamari, erikd, simonmar
      Reviewed By: bgamari
      Subscribers: rwbarton, carter
      GHC Trac Issues: #15271
      Differential Revision: https://phabricator.haskell.org/D5271
  4. 05 Sep, 2018 1 commit
    • Simon Peyton Jones's avatar
      Preserve specialisations despite CSE · 3addf72a
      Simon Peyton Jones authored
      Trac #15445 showed that, as a result of CSE, a function with an
      automatically generated specialisation RULE could be inlined
      before the RULE had a chance to fire.
      This patch attaches a NOINLINE[2] activation to the Id, during
      CSE, to stop this happening.
      See Note [Delay inlining after CSE]
      ---- Historical note ---
      This patch is simpler and more direct than an earlier
        commit 2110738b
        Author: Simon Peyton Jones <simonpj@microsoft.com>
        Date:   Mon Jul 30 13:43:56 2018 +0100
        Don't inline functions with RULES too early
      We had to revert this patch because it made GHC itself slower.
      Why? It delayed inlining of /all/ functions with RULES, and that was
      very bad in TcFlatten.flatten_ty_con_app
      * It delayed inlining of liftM
      * That delayed the unravelling of the recursion in some dictionary
      * That delayed some eta expansion, leaving
           flatten_ty_con_app = \x y. let <stuff> in \z. blah
      * That allowed the float-out pass to put sguff between
        the \y and \z.
      * And that permanently stopped eta expasion of the function,
        even once <stuff> was simplified.
      -- End of historical note ---
  5. 22 Jul, 2018 3 commits
  6. 06 Jul, 2018 1 commit
  7. 15 Jun, 2018 1 commit
    • Sylvain Henry's avatar
      Built-in Natural literals in Core · fe770c21
      Sylvain Henry authored
      Add support for built-in Natural literals in Core.
      - Replace MachInt,MachWord, LitInteger, etc. with a single LitNumber
        constructor with a LitNumType field
      - Support built-in Natural literals
      - Add desugar warning for negative literals
      - Move Maybe(..) from GHC.Base to GHC.Maybe for module dependency
      This patch introduces only a few rules for Natural literals (compared
      to Integer's rules). Factorization of the built-in rules for numeric
      literals will be done in another patch as this one is already big to
      Test Plan:
        test build with integer-simple
      Reviewers: hvr, bgamari, goldfire, Bodigrim, simonmar
      Reviewed By: bgamari
      Subscribers: phadej, simonpj, RyanGlScott, carter, hsyl20, rwbarton,
      GHC Trac Issues: #14170, #14465
      Differential Revision: https://phabricator.haskell.org/D4212
  8. 15 May, 2018 1 commit
    • Sebastian Graf's avatar
      Algebraically simplify add/sub with carry/overflow · bb338f2e
      Sebastian Graf authored
      Previously, the `{add,sub}{Int,Word}C#` PrimOps weren't handled
      in PrelRules (constant folding and algebraic simplification) at all.
      This implements the necessary logic, so that using these primitives
      isn't too punishing compared to their well-optimised, overflow-unaware
      This is so that using these primitives in `enumFromThenTo @Int` can
      be optimized by constant folding, reducing closure sizes.
      Reviewers: bgamari, simonpj, hsyl20
      Reviewed By: bgamari, simonpj
      Subscribers: AndreasK, thomie, carter
      GHC Trac Issues: #8763
      Differential Revision: https://phabricator.haskell.org/D4605
  9. 14 May, 2018 1 commit
  10. 06 May, 2018 3 commits
    • Justus Sagemüller's avatar
      Stable area hyperbolic sine for `Double` and `Float`. · 3ea33411
      Justus Sagemüller authored
      This function was unstable, in particular for negative arguments.
      The reason is that the formula `log (x + sqrt (1 + x*x))` is dominated
      by the numerical error of the `sqrt` function when x is strongly negative
      (and thus the summands in the `log` mostly cancel). However, the area
      hyperbolic sine is an odd function, thus the negative side can as well
      be calculated by flipping over the positive side, which avoids this instability.
      Furthermore, for _very_ big arguments, the `x*x` subexpression overflows. However,
      long before that happens, the square root is anyways completely dominated
      by that term, so we can neglect the `1 +` and get
          sqrt (1 + x*x) ≈ sqrt (x*x) = x
      and therefore
          asinh x ≈ log (x + x) = log (2*x) = log 2 + log x
      which does not overflow for any normal-finite positive argument, but
      perfectly matches the exact formula within the floating-point accuracy.
    • Justus Sagemüller's avatar
      Add hyperbolic functions to test of Float-inverses · d814dd38
      Justus Sagemüller authored
      The area hyperbolic sine is currently broken,
      see https://ghc.haskell.org/trac/ghc/ticket/14927.
    • Justus Sagemüller's avatar
      Add test for invertability of `Floating` methods. · be580b42
      Justus Sagemüller authored
      These functions have inverses only on part of the real line, but
      there they should be reliably inverted – that's basically the whole
      point of the functions like `asin`, `atan` etc..
  11. 19 Apr, 2018 1 commit
  12. 16 Oct, 2017 1 commit
  13. 05 Sep, 2017 1 commit
  14. 06 Mar, 2017 1 commit
  15. 03 Mar, 2017 3 commits
  16. 28 Feb, 2017 1 commit
  17. 17 Feb, 2017 1 commit
    • Simon Peyton Jones's avatar
      Simplify OutputableBndr · 0e760174
      Simon Peyton Jones authored
      This replaces three methods in OutputableBndr with one,
      and adds comments.
      There's also a tiny change in the placement of equals signs in
      debug-prints.  I like it better that way, but if it complicates
      life for anyone we can put it back.
  18. 01 Feb, 2017 1 commit
  19. 26 Jan, 2017 1 commit
    • Daishi Nakajima's avatar
      Fix the right-shift operation for negative big integers (fixes #12136) · 06b9561a
      Daishi Nakajima authored
      In `x shiftR y`, any of the following conditions cause an abort:
      - `x` is a negative big integer
      - The size of `x` and `y` is a multiple of `GMP_NUMB_BITS`
      - The bit of the absolute value of `x` is filled with `1`
      For example:
      Assuming `GMP_NUMB_BITS = 2`,  the processing of `-15 shiftR 2` is as 
      1. -15 = -1111 (twos complement: 10001)
      2. right shift 2 (as a positive number) -> 0011
      3. Due to the shift larger than GMP_NUMB_BITS, the size of the 
      destination is decreasing (2bit) -> 11
      4. Add 1, and get carry: (1) 00
      5. abort
      I fixed it that the destination size does not decrease in such a case.
      Test Plan: I tested the specific case being reported.
      Reviewers: goldfire, austin, hvr, bgamari, rwbarton
      Reviewed By: bgamari, rwbarton
      Subscribers: mpickering, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D2998
      GHC Trac Issues: #12136
  20. 22 Jan, 2017 1 commit
    • thomie's avatar
      Remove clean_cmd and extra_clean usage from .T files · 5d38fb69
      thomie authored
      The `clean_cmd` and `extra_clean` setup functions don't do anything.
      Remove them from .T files.
      Created using https://github.com/thomie/refactor-ghc-testsuite. This
      diff is a test for the .T-file parser/processor/pretty-printer in that
          find . -name '*.T' -exec ~/refactor-ghc-testsuite/Main "{}" \;
      Tests containing inline comments or multiline strings are not modified.
      Preparation for #12223.
      Test Plan: Harbormaster
      Reviewers: austin, hvr, simonmar, mpickering, bgamari
      Reviewed By: mpickering
      Subscribers: mpickering
      Differential Revision: https://phabricator.haskell.org/D3000
      GHC Trac Issues: #12223
  21. 20 Jan, 2017 1 commit
    • takano-akio's avatar
      Allow top-level string literals in Core (#8472) · d49b2bb2
      takano-akio authored
      This commits relaxes the invariants of the Core syntax so that a
      top-level variable can be bound to a primitive string literal of type
      This commit:
      * Relaxes the invatiants of the Core, and allows top-level bindings whose
        type is Addr# as long as their RHS is either a primitive string literal or
        another variable.
      * Allows the simplifier and the full-laziness transformer to float out
        primitive string literals to the top leve.
      * Introduces the new StgGenTopBinding type to accomodate top-level Addr#
      * Introduces a new type of labels in the object code, with the suffix "_bytes",
        for exported top-level Addr# bindings.
      * Makes some built-in rules more robust. This was necessary to keep them
        functional after the above changes.
      This is a continuation of D2554.
      Rebasing notes:
      This had two slightly suspicious performance regressions:
      * T12425: bytes allocated regressed by roughly 5%
      * T4029: bytes allocated regressed by a bit over 1%
      * T13035: bytes allocated regressed by a bit over 5%
      These deserve additional investigation.
      Rebased by: bgamari.
      Test Plan: ./validate --slow
      Reviewers: goldfire, trofi, simonmar, simonpj, austin, hvr, bgamari
      Reviewed By: trofi, simonpj, bgamari
      Subscribers: trofi, simonpj, gridaphobe, thomie
      Differential Revision: https://phabricator.haskell.org/D2605
      GHC Trac Issues: #8472
  22. 20 Jun, 2016 2 commits
  23. 06 Apr, 2016 2 commits
  24. 29 Mar, 2016 1 commit
  25. 20 Mar, 2016 2 commits
  26. 14 Mar, 2016 1 commit
  27. 27 Feb, 2016 1 commit
  28. 22 Jan, 2016 1 commit
    • rwbarton's avatar
      Always run test T9407 · 85e147e0
      rwbarton authored
      We don't know what the cause of the bug was, or what commit fixed it.
      or why it was Windows only. So it seems prudent to run it in all
      configurations, in case the bug should crop up again.
  29. 20 Jan, 2016 1 commit
  30. 18 Jan, 2016 1 commit
    • Simon Peyton Jones's avatar
      Refactoring on IdInfo and system derived names · ec8a188a
      Simon Peyton Jones authored
      Some modest refactoring, triggered in part by Trac #11051
      * Kill off PatSynId, ReflectionId in IdDetails
        They were barely used, and only for pretty-printing
      * Add helper function Id.mkExportedVanillaId, and use it
      * Polish up OccName.isDerivedOccName, as a predicate for
        definitions generated internally by GHC, which we
        might not want to show to the user.
      * Kill off unused OccName.mkDerivedTyConOcc
      * Shorten the derived OccNames for newtype and data
        instance axioms
      * A bit of related refactoring around newFamInstAxiomName