-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT known generic casts not elided #38106
Comments
The sharplab link is showing codegen for . Net Framework x86 jit. For core this sharplab is more relevant. Either way we're tail calling into C.AsByte2(Single)
L0000: vzeroupper
L0003: mov rax, C.As2[[System.Byte, System.Private.CoreLib]](Single)
L000d: jmp rax |
@AndyAyersMS This is a bit of common pattern that I've noticed while using Sharplab, primarily because it comes up when doing this. I've always assumed it was some bug "in the toolchain". |
The inliner has a budget that it uses to prevent runaway inlining, and it is tripping (prematurely) in this case, as (generally speaking)
That explains why the behavior changes as more checks are added -- at some point the extra IL pushes Let me look into fixing this. |
If we have a very small root method that calls a large method that is marked with AggressiveInlining, we may fail to inline because of a budget check. Allow such inlines to bypass the check. Closes dotnet#38106.
If we have a very small root method that calls a large method that is marked with AggressiveInlining, we may fail to inline because of a budget check. Allow such inlines to bypass the check. Closes #38106.
Description
When writing generic types, using a pattern as seen in
Vector<T>
(if (typeof(T) == typeof(int)) ... if (typeof(T) == typeof(float)) ...
) once this construct grows to 9 blocks JIT will end up not correctly eliding some casts:See sharplab
Removing any two blocks from
As2<T>
will improve code gen significantly (matching a non-generic version & the other version)splitting up the function will also resolve the issue.
The text was updated successfully, but these errors were encountered: