Opened 9 years ago

Last modified 6 months ago

#2988 new task

Improve float-in

Reported by: simonpj Owned by:
Priority: lowest Milestone: 8.4.1
Component: Compiler Version: 6.10.1
Keywords: Cc: baterseapower
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by bgamari)

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

...and check on performance changes, and whether FloatIn is doing the Right Thing.

Simon

Change History (16)

comment:1 Changed 9 years ago by igloo

Milestone: 6.12 branch

comment:2 Changed 8 years ago by simonmar

Type of failure: Compile-time performance bug

comment:3 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:4 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:5 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:6 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:7 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:8 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:9 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:10 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:11 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:12 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:13 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:14 Changed 2 years ago by bgamari

Milestone: 8.0.18.2.1
Type: bugtask

comment:15 Changed 2 years ago by goldfire

If you're taking this on, see also #11197, which will likely be fixed by improvements to floating-in. I don't think either of these bugs is dependent on the other exactly, but it would probably be easy to fix them both at the same time.

comment:16 Changed 6 months ago by bgamari

Description: modified (diff)
Milestone: 8.2.18.4.1
Note: See TracTickets for help on using tickets.