-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RyuJIT] Fully enregister structs that fit into a single register when profitable #8016
Comments
The issue became more important with Off-topic: I see that we are creating merge return block even if there is exactly one return, but the method is synced or profiler is enabled, do we have plans to improve that? @echesakovMSFT The groundwork to fix this issue was done in #32362, so I made a quick prototype to fix this one and was able to compile framework libraries win x64(crossgen and PMI).
Diff example for
after:
and there are 100+ methods with Nullable arguments that were improved like that, so it looks like it is the main winner, full diffs: However, the result diffs are very small and not impressive. So unless I do not find a workaround for the regressions that I see or we do not consider improved methods as performance critical I do not think it is worth finishing in this release (but possible). Maybe I have missed some opportunities to make the improvements bigger, do we know benchmarks that suffer from this issue? My raw prototype. It would need a week or so to finish (make sure all Thoughts @CarolEidt , @dotnet/jit-contrib ? Edit: we could try to avoid changes after lowering (5/11 changed files) if we replace |
IIRC, this is by design - in case of synchronized methods this is when CORINFO_HELP_MON_EXIT is called, and in case of attached profiler - this is where the JIT injects a call to the CORINFO_HELP_PROF_FCN_LEAVE hook. |
Is this from a PMI that also instantiates with Small structs are not all that common, at least in FX code, so not surprising you don't see too many diffs. FYI, your diff script is disabling loop cloning. Probably doesn't matter here, but in general you should include the impact of cloning in your diffs. |
With `Type[] typesToTry = new Type[] { default + typeof(int?) };
It could show size regressions some times that could be misleading, so I include it only with PRs changes. |
Did you look at the codegen for the simple example at the top of the issue? Overall improvement/regression ratio looks pretty good. I'd be in favor of finishing this up now since you have the context and seem confident it is just a few more days work. I would suggest spending a part of a day trying to understand the more prominent regressions, then spend two or so days working through the other issues you mention, and then check back to in to see if things still seem on track. |
Yes, it does not improve with
with
so the final code is
so this issue is more beneficial for no-retyping. I am planning to finish #37745 ignoring regressions from this issue, then try to finish it before Prev8. |
@sandreenko - I support the idea of moving forward with this for Prev8 if possible, and although it's more code I like the use of the layout info to get the register type for the structs that can fit in a register, rather than retyping the lclVars in |
This was originally issue 11407 in dotnet/coreclr, and the associated test is JIT\Regression\JitBlue\GitHub_11407. |
When a struct is small enough to fit into a register, and is only accessed in its entirety (e.g. to initialize or pass as an argument), it should be fully enregistered. Below is a simple test case that was provided with a bug filed against the desktop version. It should generate simply
xor eax; ret
on x86 and x64, but instead generates many unnecessary copies. It is addressed by full enregistration of structs that fit into a register (see work item dotnet/coreclr#7 in https://github.com/dotnet/runtime/blob/master/docs/design/coreclr/jit/first-class-structs.md#support-full-enregistration-of-struct-types):category:cq
theme:structs
skill-level:expert
cost:large
The text was updated successfully, but these errors were encountered: