Ticket #4960 (new bug)

Opened 2 years ago

Last modified 8 months ago

Better inlining test in CoreUnfold

Reported by: simonpj Owned by:
Priority: low Milestone: 7.6.2
Component: Compiler Version: 7.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Consider this

f x = let 
        $j y = case x of { True -> e1; False -> e2 }
      in
      case x of 
        True -> ...$j y1...
        False -> ...$j y2...

If a function that scrutinises its argument is applied to a constructor, it becomes much keener to inline. But in this example the function scrutinises a free variable that is evaluated to a known constructor at the call site. At the moment this is ignored, and $j may well not be inlined in situations where it would be jolly good to do so.

This shows up in test perf/should_run/MethSharing where the join points created early only inline because exprIsDupable is just generous enough to do so. If you reduce CoreUtils.dupAppSize by 1, the join point doesn't inline any more. But it should.

The solution is fairly easy: compute discounts on free varaibles as well as arguments. I'm making a ticket because I don't want to execute on this today.

Change History

Changed 2 years ago by igloo

  • milestone set to 7.4.1

Changed 22 months ago by simonpj

See #3781, #3755, which would find this optimisation useful.

Changed 16 months ago by igloo

  • priority changed from normal to low
  • milestone changed from 7.4.1 to 7.6.1

Changed 8 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.