Keep structs in registers #43867
Epic for improving the ability of the JIT to keep structs in registers.
The JIT currently supports keeping structs in registers when the individual fields are promoted to local variables (also known as scalar replacement). However, there are a number of cases where it forces them to the stack. Some of these cases are more fundamental, e.g. when they are address exposed. Others, however, are due to JIT limitations in handling argument passing and returns.
The Jit does not support keeping small structs in registers when the fields are not promoted and not accessed, for example, when the struct is only used as an argument or block.
.NET 6 scope:
Work items for multi-reg
Work items for single-reg
Stretch goals for 6.0:
Stretch goal for multi-reg:
Stretch goal for single-reg:
.NET 6 Result:
We have a set of repro-tests that show incorrect/inefficient code generation in 5.0 that is expected to be fixed. It is covered by issues in the previous section.
The perf results are shown in the bottom messages.
The text was updated successfully, but these errors were encountered:
some additional test casts that I am planning to improve in this issue for 6.0:
with a small struct enreg we are going to get:
it is a wider case of #8016.
Also, I got estimates of the expected perf results using a local branch with fixed morph (improvements are in addition to what already have been merged):
With #55558 and #55727 we finished struct optimizations in 6.0 scope and soon I will open new work items for 7.0.
There were also many fixes for struct, especially with passing float in int regs or in SIMD types.
The additional checks and cleanups should help us against silent bad codegen cases that we saw in the past releases.
It is hard to gather performance wins for 7.0 changes because there were many of them, but if we just some asm diffs from the main PR we will get something like:
PRshttps://github.com//pull/55558 https://github.com//pull/55045 https://github.com//pull/55727 https://github.com//pull/52292 https://github.com//pull/49879 https://github.com//pull/48377 https://github.com//pull/45824
x64 windows pmi libraries:
arm64 linux pmi libraries: