[commit: ghc] ghc-8.2: Cure exponential behaviour in the simplifier (9b58c63)

git at git.haskell.org git at git.haskell.org
Fri Apr 28 18:28:02 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/9b58c6360b9c2dc5b15c17ba83f5dc729efb84dc/ghc

>---------------------------------------------------------------

commit 9b58c6360b9c2dc5b15c17ba83f5dc729efb84dc
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Apr 26 17:31:36 2017 +0100

    Cure exponential behaviour in the simplifier
    
    This patch nails a Bad Bug exposed in Trac #13379. Roughly,
    a deeply-nested application like
       f (f (f ....) ) )
    could make the simplifier go exponential -- without producing
    an exponential-sized result!
    
    The reason was that we
      - simplified a (big) function argument
      - then decided to inline the function
      - then preInilneUnconditionally the argument
      - and then re-simplified the big argument
    
    And if the "big argument" itself had a similar structure
    things could get very bad.
    
    Once I'd understood, it was easy to fix:
    
    * See Note Note [Avoiding exponential behaviour] for an overview
    
    * The key change is that Simplify.simplLam now as a case for
      (isSimplified dup). This is what removes the perf bug.
    
    * But I also made simplCast more parsimonious about simplifying,
      avoiding doing so when the coercion is Refl
    
    * And similarly I now try to avoid simplifying arguments
      where possible before applying rules.
      See Note [Trying rewrite rules]
    
    The latter two points tackle common cases, and in those cases make the
    simplifier take fewer iterations.
    
    (cherry picked from commit a1b753e8b1475659440f524b3e66dfbea31c5787)


>---------------------------------------------------------------

9b58c6360b9c2dc5b15c17ba83f5dc729efb84dc
 compiler/simplCore/SimplUtils.hs                   |  35 +-
 compiler/simplCore/Simplify.hs                     | 175 +++++++---
 testsuite/tests/perf/compiler/T13379.hs            | 372 +++++++++++++++++++++
 testsuite/tests/perf/compiler/T4007.stdout         |   2 +-
 testsuite/tests/perf/compiler/all.T                |  16 +-
 .../tests/simplCore/should_compile/T3234.stderr    |  20 +-
 6 files changed, 549 insertions(+), 71 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 9b58c6360b9c2dc5b15c17ba83f5dc729efb84dc


More information about the ghc-commits mailing list