[JIT] Codegen issue for InlineArray
in record
#110968
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
tenet-performance
Performance related issue
Milestone
Overview
I found a particular case where access to
InlineArray
s are surprisingly slow in my application. Here's a repro, also on SharpLab:Good codegen, for
class
(Detail: I don't think this should allocate stack space. Probably left after the rest was optimized.)
Suboptimal codegen, for
record class
Analysis
I could only reproduce this problem by combining
InlineArray
withrecord class
. Other types don't lead to this codegen. It seems that the field access via getter is problematic. Because the getter returns the wholeInlineArray
the JIT appears to everything to the stack before accessing it. If you make theInlineArray
bigger, the problem becomes worse/more obvious.The stack probe for an 64k-sized
InlineArray
look like this:The
rsp+rax+0x10020
encoding is curious, as it could be reformulated asrsp+0x30
instead. I'm not so sure this is important though.Workaround
The
ARecordClassWorkaround
version results in fast code.Regression
Tested with .NET 9.0.0. Unclear if regression or not.
The text was updated successfully, but these errors were encountered: