Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,316
    • Issues 4,316
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 387
    • Merge Requests 387
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Merge Requests
  • !4553

Open
Opened Dec 01, 2020 by Sebastian Graf@sgraf812Developer
  • Report abuse
Report abuse

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b "wip/T18962" "origin/wip/T18962"

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout "master"
git merge --no-ff "wip/T18962"

Step 4. Push the result of the merge to GitLab

git push origin "master"

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

WIP: SAT: Attach SAT'd definition as INLINABLE unfolding

  • Overview 13
  • Commits 11
  • Pipelines 9
  • Changes 13

SAT is most beneficial if we can specialise a recursive function for the static arguments at a call site by inlining it.

From the standpoint of generated code, the SAT'd definition is very often inferior and will be inverted by our selective lambda lifting pass, which runs late in the STG pipeline.

So we don't even want to execute the SAT'd code, just inline it if we can! Thus, in this MR I

  1. Implement a new (but dead simple) SA analysis pass that just analyses for static arguments, populating idStaticArgs. Run this analysis before each Simplifier run, directly after Occurrence Analysis.
  2. Attach the SAT'd inlining in the Simplifier in simplLetUnfolding, based on idStaticArgs.
  3. Apply it through a new special case in callSiteInline, which allows loop breakers with idStaticArgs to inline their SAT'd unfolding

Hopefully fixes #18962.

Also in the OP #9374, Max Bolingbroke wrote that the main reason to withhold SAT from -O2 was that it spoiled tail calls in "high-performacne Haskell". I think that will no longer be the case with this patch, as the generated code (should the binding not be inlined) is unaffected and the unfolding will end up with exactly the same tail call structure if inlined.

Here are preliminary NoFib results (there's still room for improvement, I believe):

NoFib Results

--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
    constraints          -2.4%     +2.8%
            fft          -1.0%     -1.8%
         genfft          -2.6%    -12.3%
             gg           0.0%     -2.5%
      listcompr          -0.4%     -1.1%
       listcopy          -0.4%     -1.0%
           para          -0.5%     +0.3%
        parstof          -0.7%     -1.6%
        rewrite          -0.8%     -0.3%
      transform          -0.5%     -0.8%
      typecheck          -2.8%     -2.5%
           wang          -1.1%     -1.2%
      wave4main          -0.2%     -1.1%
--------------------------------------------------------------------------------
            Min          -2.8%    -12.3%
            Max          +0.2%     +2.8%
 Geometric Mean          -0.1%     -0.2%

Allocation and instructions increased by about 3% while compiling NoFib, but remember that currently we run the new SA analysis pass on each iteration of the Simplifier.

Edited Dec 10, 2020 by Sebastian Graf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
Reference: ghc/ghc!4553
Source branch: wip/T18962