Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9796 closed task (fixed)

Implement amap/coerce rule for `Array`

Reported by: dfeuer Owned by: dfeuer
Priority: normal Milestone: 7.10.1
Component: Core Libraries Version: 7.9
Keywords: Cc: core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: #8767 Differential Rev(s): Phab:D471
Wiki Page:


We have map/coerce; there's no reason not to have amap/coerce as well.

Change History (4)

comment:1 Changed 5 years ago by dfeuer

Differential Rev(s): Phab:D471
Status: newpatch

Doing this required me to delay inlining amap until phase 1, which required me to rewrite it to avoid relying on list fusion. This has a nice side benefit: the compiled code ends up smaller because it avoids a redundant test relating to enumFromTo and redundant array freezing code that went with it.

comment:2 Changed 5 years ago by Herbert Valerio Riedel <hvr@…>

In 603b7be7bd3abaf0e2c210e8d9015b1d613b4715/ghc:

Implement amap/coerce for Array (re #9796)

Implement an `amap`/`coerce` rule in `GHC.Arr` to match the
`map`/`coerce` rule in GHC.Base.

In order to do so, delay inlining `amap` until phase 1.

To prevent the inlining delay from causing major inefficiencies due to
missed list fusion, rewrite `amap` to avoid relying on list fusion. This
has the extra benefit of reducing the size of the compiled amap code by
skipping the impossible case of an array with a negative size.

Reviewed By: nomeata

Differential Revision:

comment:3 Changed 5 years ago by thomie

Resolution: fixed
Status: patchclosed

comment:4 Changed 5 years ago by thomie

Note: See TracTickets for help on using tickets.