1. 28 Feb, 2017 1 commit
    • rwbarton's avatar
      When floating, don't box an expression that's okay for speculation (#13338) · d0508ef0
      rwbarton authored
      Commit 432f952e (Float unboxed expressions by boxing) lets the float-out pass
      turn, for example,
      
          ... (-# (remInt# x# 100000#) i#) ...
      
      into
      
          let lvl :: Int
              lvl = case remInt# x# 100000# of v { __DEFAULT__ -> I# v }
          in ... (-# (case lvl of { I# v -> v }) i#) ...
      
      But when, as in the example above, the expression that was floated out was
      the argument of an application, the resulting application may no longer
      satisfy the let/app invariant, because exprOkForSpeculation doesn't look
      far enough inside the definition of lvl.
      
      Solution: When the expression we floated out was okay for speculation, don't
      bother boxing it. It will be evaluated earlier, and that's okay by assumption.
      Fixes the let/app invariant and is cheaper too.
      
      Test Plan: make slowtest TEST=T13338
      
      Reviewers: austin, bgamari, simonpj
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3217
      d0508ef0
  2. 26 Feb, 2017 2 commits
    • rwbarton's avatar
      tests: remove extra_files.py (#12223) · 3415bcaa
      rwbarton authored
      The script I used is included as testsuite/driver/kill_extra_files.py,
      though at this point it is for mostly historical interest.
      
      Some of the tests in libraries/hpc relied on extra_files.py, so this
      commit includes an update to that submodule.
      
      One test in libraries/process also relies on extra_files.py, but we
      cannot update that submodule so easily, so for now we special-case it
      in the test driver.
      3415bcaa
    • Ben Gamari's avatar
      Add testcase for #13340 · 517ad201
      Ben Gamari authored
      Test Plan: Validate
      
      Reviewers: rwbarton, austin
      
      Reviewed By: rwbarton
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3215
      517ad201
  3. 24 Feb, 2017 1 commit
    • Simon Peyton Jones's avatar
      Make exprIsConApp_maybe work better for literals strings · a6e13d50
      Simon Peyton Jones authored
      There are two things here
      
      * Use exprIsLiteral_maybe to "look through" a variable bound
        to a literal string.
      
      * Add CONLIKE to the NOINLINE pragma for unpackCString# and
        unpackCStringUtf8#
      
      See Trac #13317, Trac #10844, and
      Note [exprIsConApp_maybe on literal strings] in CoreSubst
      
      I did a nofib run and got essentially zero change except for one
      2.2% improvement in allocation for 'pretty'.
      a6e13d50
  4. 06 Feb, 2017 1 commit
    • Eric Seidel's avatar
      Do Worker/Wrapper for NOINLINE things · b572aadb
      Eric Seidel authored
      Disabling worker/wrapper for NOINLINE things can cause unnecessary
      reboxing of values. Consider
      
          {-# NOINLINE f #-}
          f :: Int -> a
          f x = error (show x)
      
          g :: Bool -> Bool -> Int -> Int
          g True  True  p = f p
          g False True  p = p + 1
          g b     False p = g b True p
      
      the strictness analysis will discover f and g are strict, but because f
      has no wrapper, the worker for g will rebox p. So we get
      
          $wg x y p# =
            let p = I# p# in  -- Yikes! Reboxing!
            case x of
              False ->
                case y of
                  False -> $wg False True p#
                  True -> +# p# 1#
              True ->
                case y of
                  False -> $wg True True p#
                  True -> case f p of { }
      
          g x y p = case p of (I# p#) -> $wg x y p#
      
      Now, in this case the reboxing will float into the True branch, an so
      the allocation will only happen on the error path. But it won't float
      inwards if there are multiple branches that call (f p), so the reboxing
      will happen on every call of g. Disaster.
      
      Solution: do worker/wrapper even on NOINLINE things; but move the
      NOINLINE pragma to the worker.
      
      Test Plan: make test TEST="13143"
      
      Reviewers: simonpj, bgamari, dfeuer, austin
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: dfeuer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3046
      b572aadb
  5. 01 Feb, 2017 1 commit
  6. 24 Jan, 2017 1 commit
    • rwbarton's avatar
      Re-sort case alternatives after scrutinee constant folding (#13170) · abaa6815
      rwbarton authored
      Commit d3b546b1 added a "scrutinee constant folding" pass
      that rewrites a case expression whose scrutinee is an expression like
      x +# 3#. But case expressions are supposed to have their alternatives in
      sorted order, so when the scrutinee is (for example) negateInt# x#, we
      need to re-sort the alternatives after mapping their values.
      
      This showed up as a core lint failure when compiling System.Process.Posix:
      
          isSigIntQuit n = sig == sigINT || sig == sigQUIT
              where sig = fromIntegral (-n)
      
      Data.List.sortBy is supposed to be linear-time on sorted or reverse-sorted
      input, so it is probably not worth doing anything more clever than this.
      
      Test Plan: Added a new test T13170 for the above case.
      
      Reviewers: austin, hsyl20, simonpj, bgamari
      
      Reviewed By: hsyl20, simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3008
      
      GHC Trac Issues: #13170
      abaa6815
  7. 22 Jan, 2017 1 commit
  8. 20 Jan, 2017 4 commits
    • 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
      Addr#.
      
      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#
        bindings.
      
      * 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
      d49b2bb2
    • Simon Peyton Jones's avatar
      Test Trac #11444 · b8f1b018
      Simon Peyton Jones authored
      b8f1b018
    • Simon Peyton Jones's avatar
      Simplify and improve CSE · b78fa759
      Simon Peyton Jones authored
      Trac #13156 showed a lost opportunity for CSE. I found that it was
      easy to fix, and it had the nice side effect of rendering a previous
      nasty case, described in Note [Corner case for case expressions],
      unnecessary.
      
      Simpler code, does more.  Great.
      b78fa759
    • Simon Peyton Jones's avatar
      Fix a nasty bug in exprIsExpandable · 9be18ea4
      Simon Peyton Jones authored
      This bug has been lurking for ages: Trac #13155
      
      The important semantic change is to ensure that exprIsExpandable
      returns False for primop calls.  Previously exprIsExpandable used
      exprIsCheap' which always used primOpIsCheap.
      
      I took the opportunity to combine the code for exprIsCheap' (two
      variants: exprIsCheap and exprIsExpandable) with that for
      exprIsWorkFree.  Result is simpler, tighter, easier to understand.
      And correct (at least wrt this bug)!
      9be18ea4
  9. 23 Dec, 2016 4 commits
    • Sylvain Henry's avatar
      Fix test for T12877 · 1b06231e
      Sylvain Henry authored
      Summary: See https://phabricator.haskell.org/rGHCd3b546b1a605
      
      Reviewers: nomeata, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2883
      1b06231e
    • Simon Peyton Jones's avatar
      Push coercions in exprIsConApp_maybe · b4c3a668
      Simon Peyton Jones authored
      Trac #13025 showed up the fact that exprIsConApp_maybe isn't
      clever enough: it didn't push coercions through applicatins, and that
      meant we weren't getting as much superclass selection as we should.
      
      It's easy to fix, happily.
      
      See Note [Push coercions in exprIsConApp_maybe]
      b4c3a668
    • Simon Peyton Jones's avatar
      Propagate evaluated-ness a bit more faithfully · 75e8c305
      Simon Peyton Jones authored
      This was provoked by Trac #13027.
      
      The fix in Simplify actually cures the reported bug; see
      Note [Case binder evaluated-ness] in Simplify.
      
      The fix in CoreTidy looks like an omission that I fixed while I
      was at it.
      75e8c305
    • Simon Peyton Jones's avatar
      Float unboxed expressions by boxing · 432f952e
      Simon Peyton Jones authored
      This patch makes GHC's floating more robust, by allowing it
      to float unboxed expressions of at least some common types.
      
      See Note [Floating MFEs of unlifted type] in SetLevels.
      
      This was all provoked by Trac #12603
      
      In working this through I also made a number of other corner-case
      changes in SetLevels:
      
      * Previously we inconsistently use exprIsBottom (which checks for
        bottom) instead of exprBotStrictness_maybe (which checks for
        bottoming functions).  As well as being inconsistent it was
        simply less good.
      
        See Note [Bottoming floats]
      
      * I fixed a case where were were unprofitably floating an
        expression because we thought it escaped a value lambda
        (see Note [Escaping a value lambda]).  The relevant code is
             float_me = (dest_lvl `ltMajLvl` (le_ctxt_lvl env)
                        && not float_is_lam)   -- NEW
      
      * I made lvlFloatRhs work properly in the case where abs_vars
        is non-empty.  It wasn't wrong before, but it did some stupid
        extra floating.
      432f952e
  10. 21 Dec, 2016 1 commit
  11. 13 Dec, 2016 1 commit
  12. 12 Dec, 2016 1 commit
    • Simon Peyton Jones's avatar
      Float unboxed expressions by boxing · bc3d37da
      Simon Peyton Jones authored
      This patch makes GHC's floating more robust, by allowing it
      to float unboxed expressions of at least some common types.
      
      See Note [Floating MFEs of unlifted type] in SetLevels.
      
      This was all provoked by Trac #12603
      bc3d37da
  13. 28 Nov, 2016 1 commit
  14. 05 Sep, 2016 1 commit
  15. 30 Aug, 2016 1 commit
  16. 21 Aug, 2016 2 commits
  17. 21 Jun, 2016 1 commit
  18. 09 Jun, 2016 1 commit
  19. 18 May, 2016 1 commit
  20. 17 May, 2016 1 commit
    • thomie's avatar
      Testsuite: run tests in /tmp after copying required files · 3f3dc23e
      thomie authored
      Major change to the testsuite driver.
      
      For each TEST:
         * create a directory `<testdir>` inside `/tmp`.
      
         * link/copy all source files that the test needs into `<testdir>`.
      
         * run the test inside `<testdir>`.
      
         * delete `<testdir>`
      
      Extra files are (temporarily) tracked in
      `testsuite/driver/extra_files.py`, but can also be specified using the
      `extra_files` setup function.
      
      Differential Revision: https://phabricator.haskell.org/D1187
      
      Reviewed by: Rufflewind, bgamari
      
      Trac: #11980
      3f3dc23e
  21. 22 Apr, 2016 1 commit
  22. 24 Mar, 2016 1 commit
    • Simon Peyton Jones's avatar
      Tidy up handling of coercion variables · cb08f8da
      Simon Peyton Jones authored
      * Comments to explain that a CoVar, whose IdInfo is CoVarId,
        is always unlifted (but may be nominal or representational role)
      
        And TyCoRep.isCoercionType picks out only those unlifted
        types, NOT the lifted versions
      
      * Introduce Var.NcId for non-co-var Ids
        with predicate isNonCoVarId
      
      * Add assertions in CoreSubst that the Id env is only
        used for NcIds
      
      * Fix lurking bug in CSE which extended the
        CoreSubst Id env with a CoVar
      
      * Fix two bugs in Specialise.spec_call, which wrongly treated
        CoVars like NcIds
          - needed a varToCoreExpr in one place
          - needed extendSubst not extendIdSubst in another
        This was the root cause of Trac #11644
      
      Minor refactoring
      
      * Eliminate unused mkDerivedLocalCoVarM, mkUserLocalCoVar
      * Small refactor in mkSysLocalOrCoVar
      cb08f8da
  23. 23 Mar, 2016 1 commit
  24. 25 Feb, 2016 2 commits
  25. 11 Feb, 2016 1 commit
    • Simon Peyton Jones's avatar
      Always do eta-reduction · 85008555
      Simon Peyton Jones authored
      See Note [Eta-reduction in -O0] in DynFlags.
      
      Bottom line: doing eta reduction unconditionally is benign, and
      removes an ASSERT failure (Trac #11562).
      85008555
  26. 17 Dec, 2015 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #11232. · cab13162
      eir@cis.upenn.edu authored
      I somehow forgot to propagate roles into UnivCos. Very
      simple fix, happily.
      
      Test Plan: simplCore/should_compile/T11232
      
      Reviewers: bgamari, austin, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1645
      
      GHC Trac Issues: #11232
      cab13162
  27. 04 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      Case-of-empty-alts is trivial (Trac #11155) · 1c9fd3f1
      Simon Peyton Jones authored
      As you'll see from Trac #11155, the code generator was confused
      by a binding let x = y in ....   Why did that happen? Because of
      a (case y of {}) expression on the RHS.
      
      The right thing is just to expand what a "trivial" expression is.
      
      See Note [Empty case is trivial] in CoreUtils.
      1c9fd3f1
  28. 23 Sep, 2015 1 commit
  29. 30 Jul, 2015 1 commit
    • Simon Peyton Jones's avatar
      Deal with phantom type variables in rules · 4e8d74d2
      Simon Peyton Jones authored
      See Note [Unbound template type variables] in Rules.hs
      This fixes Trac #10689.
      
      The problem was a rule LHS that mentioned a type variable
      in a phantom argument to a type synonym.  Then matching the
      LHS didn't bind the type variable, and the rule matcher
      complained.
      
      This patch fixes the problem, as described by the Note.
      
      I also went back to not-cloning the template varaibles during
      rule matching.  I'm convinced that it's not necessary now
      (if it ever was), and cloning makes the fix for #10689 much more
      fiddly.
      4e8d74d2
  30. 22 Jul, 2015 1 commit
  31. 21 Jul, 2015 1 commit
    • Simon Peyton Jones's avatar
      T4945 is working again · 35eb736b
      Simon Peyton Jones authored
      This test keeps flipping between ok and not-ok.  In some ways
      this isn't surprising, since it greps in the output of
      -ddump-simpl, but I wish I knew exactly why.  Anyway,
      it's currently working again.
      35eb736b