Generate straightline code for inline array allocation
authorMichal Terepeta <michal.terepeta@gmail.com>
Sat, 30 Mar 2019 17:36:36 +0000 (18:36 +0100)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Mon, 8 Apr 2019 18:29:34 +0000 (14:29 -0400)
commit63b7d5fb9d695dafc243cbf6f9f70b06030c0dea
tree468304a4f8f6083c367a34ccf50142357e6db311
parent3a38ea4487173f0f8e3693a75d1c5c7d33f12f05
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.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
compiler/codeGen/StgCmmPrim.hs
testsuite/tests/codeGen/should_run/NewSmallArray.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/NewSmallArray.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/all.T