Skip to content

Generate straightline code for inline array allocation

GHC has an optimization for allocating arrays when the size is statically known -- it'll generate the code allocating and initializing the array inline (instead of a call to a procedure from rts/PrimOps.cmm).

However, the generated code uses a loop to do the initialization. Since we already check that the requested size is small (we check against maxInlineAllocSize), we can generate faster straightline code instead. This brings about 15% improvement for newSmallArray# in my testing and slightly simplifies the code in GHC.

Merge request reports