Opened 17 months ago

Last modified 9 months ago

#15127 new bug

Unbox around runRW#

Reported by: dfeuer Owned by:
Priority: low Milestone: 8.10.1
Component: Compiler Version: 8.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Because runRW# inlines so late, we don't end up unboxing around it. For example, suppose we write

f x = runST $ do
  mar <- newArray 100 x
  unsafeFreeze mar

This will compile to something like

f x = case runRW# (\s ->
        case newArray# 100# x s of { (# s', mar #) ->
        case unsafeFreezeArray# mar s' of { (# s'', ar# #) ->
          (# s'', Array ar# #) }}) of
         (# _, ar #) -> ar

We generally want to pull the constructor application out of the runRW# argument:

f x = case runRW# (\s ->
        case newArray# 100# x s of { (# s', mar #) ->
          unsafeFreezeArray# mar s' }) of
        (# _, ar# #) -> Array ar#

This exposes the Array constructor to case-of-case.

Change History (2)

comment:1 Changed 16 months ago by simonpj

See also #13014

comment:2 Changed 9 months ago by osa1

Milestone: 8.8.18.10.1

Bumping milestones of low-priority tickets.

Note: See TracTickets for help on using tickets.