<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>



<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<h3>
Simon Peyton Jones pushed to branch wip/T13253
at <a href="https://gitlab.haskell.org/ghc/ghc">Glasgow Haskell Compiler / GHC</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/d738eb62e987fb3179756010e3ce6d4016e70f09">d738eb62</a></strong>
<div>
<span>by Simon Peyton Jones</span>
<i>at 2020-07-27T10:04:32+01:00</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap; margin: 0;">This patch addresses the exponential blow-up in the simplifier.

Specifically:
  #13253 exponential inlining
  #10421 ditto
  #18140 strict constructors
  #18282 another nested-function call case

This patch makes one really significant changes: change the way that
mkDupableCont handles StrictArg.  The details are explained in
GHC.Core.Opt.Simplify Note [Duplicating StrictArg].

Specific changes

* In mkDupableCont, when making auxiliary bindings for the other arguments
  of a call, add extra plumbing so that we don't forget the demand on them.
  Otherwise we haev to wait for another round of strictness analysis. But
  actually all the info is to hand.  This change affects:
  - Make the strictness list in ArgInfo be [Demand] instead of [Bool],
    and rename it to ai_dmds.
  - Add as_dmd to ValArg
  - Simplify.makeTrivial takes a Demand
  - mkDupableContWithDmds takes a [Demand]

There are a number of other small changes

1. For Ids that are used at most once in each branch of a case, make
   the occurrence analyser record the total number of syntactic
   occurrences.  Previously we recorded just OneBranch or
   MultipleBranches.

   I thought this was going to be useful, but I ended up barely
   using it; see Note [Note [Suppress exponential blowup] in
   GHC.Core.Opt.Simplify.Utils

   Actual changes:
     * See the occ_n_br field of OneOcc.
     * postInlineUnconditionally

2. I found a small perf buglet in SetLevels; see the new
   function GHC.Core.Opt.SetLevels.hasFreeJoin

3. Remove the sc_cci field of StrictArg.  I found I could get
   its information from the sc_fun field instead.  Less to get
   wrong!

4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler
   invariant: they line up with the value arguments beyond ai_args
   This allowed a bit of nice refactoring; see isStrictArgInfo,
   lazyArgcontext, strictArgContext

There is virtually no difference in nofib. (The runtime numbers
are bogus -- I tried a few manually.)

        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
            fft          +0.0%     -2.0%    -48.3%    -49.4%      0.0%
     multiplier          +0.0%     -2.2%    -50.3%    -50.9%      0.0%
--------------------------------------------------------------------------------
            Min          -0.4%     -2.2%    -59.2%    -60.4%      0.0%
            Max          +0.0%     +0.1%     +3.3%     +4.9%      0.0%
 Geometric Mean          +0.0%     -0.0%    -33.2%    -34.3%     -0.0%

Test T18282 is an existing example of these deeply-nested strict calls.
We get a big decrease in compile time (-85%) because so much less
inlining takes place.

Metric Decrease:
    T18282
</pre>
</li>
</ul>
<h4>30 changed files:</h4>
<ul>
<li class="file-stats">
<a href="#783e5dae6e86931f06700fc088fb7d48c8a07386">
compiler/GHC/Core/Coercion.hs
</a>
</li>
<li class="file-stats">
<a href="#bac3d5159a5688007de3aa3f5c4e50569677b347">
compiler/GHC/Core/Opt/OccurAnal.hs
</a>
</li>
<li class="file-stats">
<a href="#cc763cdd1967f5d921161a32f64136cfcf0332c5">
compiler/GHC/Core/Opt/SetLevels.hs
</a>
</li>
<li class="file-stats">
<a href="#f168a93cde5e2aec2441d6331dfe500172df4af3">
compiler/GHC/Core/Opt/Simplify.hs
</a>
</li>
<li class="file-stats">
<a href="#48fbb5cdea308650de5756521feb28ec68819b9b">
compiler/GHC/Core/Opt/Simplify/Utils.hs
</a>
</li>
<li class="file-stats">
<a href="#11ffe98a94d798427bc600e4fcfe899407536346">
compiler/GHC/Core/SimpleOpt.hs
</a>
</li>
<li class="file-stats">
<a href="#166e3514d27c63ef7e86af29830d9e8b2a31c8b1">
compiler/GHC/Types/Basic.hs
</a>
</li>
<li class="file-stats">
<a href="#d09e98aae6ad2eb59d08eac7894b68c0ab820cda">
compiler/GHC/Types/Demand.hs
</a>
</li>
<li class="file-stats">
<a href="#38110817cdbc9a34d2b80a14070cabc7515c808a">
compiler/GHC/Types/Id/Info.hs
</a>
</li>
<li class="file-stats">
<a href="#68981928c0d335390bba962b95dc1104a8881d05">
testsuite/tests/numeric/should_compile/T14465.stdout
</a>
</li>
<li class="file-stats">
<a href="#e6a25af732cafed9cd91b716ddbdb29b303bd865">
testsuite/tests/numeric/should_compile/T7116.stdout
</a>
</li>
<li class="file-stats">
<a href="#9856dc5a4674b6f62977f48c1f04853d4a567961">
<span class="new-file">
+
testsuite/tests/perf/compiler/T10421.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#0184e9a52eb2baf5f839713779cf06cac224d755">
<span class="new-file">
+
testsuite/tests/perf/compiler/T10421_Form.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#fc1b1f4f4d3cd9abfc943223dfcfaa28517401c4">
<span class="new-file">
+
testsuite/tests/perf/compiler/T10421_Y.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#feea1d1b4e41d18c5ffaa41c547dbf7885b236d7">
<span class="new-file">
+
testsuite/tests/perf/compiler/T10421a.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#6cded300cd59c6c6bd64f4fe380e9248a339c2bf">
<span class="new-file">
+
testsuite/tests/perf/compiler/T13253-spj.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#2546b50520bb12b5295e3396e1c0f536b4a19c47">
<span class="new-file">
+
testsuite/tests/perf/compiler/T13253.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#0ec8c7a42ce4c1d4caa408ab9cde327d64463cbf">
<span class="new-file">
+
testsuite/tests/perf/compiler/T18140.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#fd4a0b65d74153aed8b33b01a04eb3ff7442cd45">
testsuite/tests/perf/compiler/all.T
</a>
</li>
<li class="file-stats">
<a href="#6e2ce964ea02e92c2202946150700a3219beed86">
testsuite/tests/simplCore/should_compile/T13143.stderr
</a>
</li>
<li class="file-stats">
<a href="#bbbedc83ff419605896829035ab2d4207fb9987b">
testsuite/tests/simplCore/should_compile/T15631.stdout
</a>
</li>
<li class="file-stats">
<a href="#76b1e7dce1b4954525a28c2fed28ba31ca27a964">
testsuite/tests/simplCore/should_compile/T17901.stdout
</a>
</li>
<li class="file-stats">
<a href="#567031a571455045b61cacbcb7f3806ae34cd4f6">
testsuite/tests/simplCore/should_compile/T18355.stderr
</a>
</li>
<li class="file-stats">
<a href="#240f515f83d0d2bd4f3fd8627a432213afbc9d16">
testsuite/tests/simplCore/should_compile/T3717.stderr
</a>
</li>
<li class="file-stats">
<a href="#ae44213f400f8badeaf992dd66c7c6bfd26ffd60">
testsuite/tests/simplCore/should_compile/T3772.stdout
</a>
</li>
<li class="file-stats">
<a href="#4f7d2e4c54691e357987d9c38d83118a9835128f">
testsuite/tests/simplCore/should_compile/T4908.stderr
</a>
</li>
<li class="file-stats">
<a href="#9b7fb90328b6862556fa185afce25159a399f92f">
testsuite/tests/simplCore/should_compile/T4930.stderr
</a>
</li>
<li class="file-stats">
<a href="#d924e7713114c6fd54c73468a4bb4b42ec5da1db">
testsuite/tests/simplCore/should_compile/T5366.stdout
</a>
</li>
<li class="file-stats">
<a href="#0e264f20bcb9f21ef8f19196ea35fb751107dd1f">
testsuite/tests/simplCore/should_compile/T7360.stderr
</a>
</li>
<li class="file-stats">
<a href="#e9ed289bdfe6bcb0204e76be84b2f377004a5d3d">
testsuite/tests/simplCore/should_compile/T7865.stdout
</a>
</li>
</ul>
<h5>The diff was not included because it is too large.</h5>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
<a href="https://gitlab.haskell.org/ghc/ghc/-/commit/d738eb62e987fb3179756010e3ce6d4016e70f09">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.haskell.org.
If you'd like to receive fewer emails, you can
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.haskell.org/ghc/ghc/-/commit/d738eb62e987fb3179756010e3ce6d4016e70f09"}}</script>


</p>
</div>
</body>
</html>