Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,869
    • Issues 4,869
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2988
Closed
Open
Created Jan 29, 2009 by Simon Peyton Jones@simonpjDeveloper

Improve float-in

At the moment we can get a cascade of simplifier iterations like this:

let x1 = blah
    x2 = x1 : []
    x3 = 1 : x2
    x4 = 2 : x3
in case blah of
  True -> f x4
  False -> g x4

Then x4 satisfies the conditions for postInlineUnconditionally (not top-level, used once in each case branch, not inside lambda). So it's inlined. In the next iteration of the simplifier, x3 satisfies the conditions, and so on.

It might be better for postUnconditionally to require an interesting context. But then this case doesn't work so well:

   let x = blah in case foo of { A -> ..x..; B -> ..x..; C -> ..no x.. }

If C is the hot branch, it's a good idea to push x into the A,B branches.

But perhaps this question is one that FloatIn should deal with, not postInlineUnconditionally. Indeed FloatIn has the following comment:

		-- For case expressions we duplicate the binding if it is
		-- reasonably small, and if it is not used in all the RHSs
		-- This is good for situations like
		--	let x = I# y in
		--	case e of
		--	  C -> error x
		-- 	  D -> error x
		--	  E -> ...not mentioning x...

So this ticket is just to record the idea:

  • Make postInlineUnconditionally check for interesting context
  1. ..and check on performance changes, and whether FloatIn is doing the Right Thing.

Simon

Edited Mar 10, 2019 by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking