-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fold BOX+ISINST to null if possible #88989
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
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@MihuBot -tier0 |
src/coreclr/jit/importer.cpp
Outdated
| if ((opts != BoxPatterns::MakeInlineObservation) && | ||
| ((impStackTop().val->gtFlags & GTF_SIDE_EFFECT) == 0)) | ||
| { | ||
| if ((opts == BoxPatterns::IsByRefLike) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do this for byref-like types? Note that the exact patterns that are supported for them is documented here and I think it is expected that other patterns continue throwing (or, alternatively, that the pattern is documented).
A separate question -- doesn't this logic essentially subsume the logic that happens below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate question -- doesn't this logic essentially subsume the logic that happens below?
Sort of, in this case we only handle MustNot case while the logic below handles both Must and MustNot - I tried to share them but decided that it's not worth it, also, removed nullable<> support since it didn't add any diffs
Should we do this for byref-like types?
Let me remove it then and keep only the patterns listed there then
Closes #88987
Tier0 Codegen diff for
Test<int>:; Assembly listing for method Program:Test[int](int) (Tier0) push rbp sub rsp, 48 lea rbp, [rsp+30H] xor eax, eax mov qword ptr [rbp-08H], rax - mov qword ptr [rbp-10H], rax mov dword ptr [rbp+10H], ecx - mov rcx, 0xD1FFAB1E ; System.Int32 - call CORINFO_HELP_NEWSFAST - mov gword ptr [rbp-10H], rax - mov rdx, gword ptr [rbp-10H] - mov ecx, dword ptr [rbp+10H] - mov dword ptr [rdx+08H], ecx - mov rdx, gword ptr [rbp-10H] - mov rcx, 0xD1FFAB1E ; System.Collections.IEnumerable - call [CORINFO_HELP_ISINSTANCEOFINTERFACE] - mov gword ptr [rbp-08H], rax + xor rcx, rcx + mov gword ptr [rbp-08H], rcx cmp gword ptr [rbp-08H], 0 je SHORT G_M5413_IG03 mov rcx, gword ptr [rbp-08H] call [Program:Consume(System.Object)] G_M5413_IG03: nop add rsp, 48 pop rbp ret -; Total bytes of code 100 +; Total bytes of code 49Consumecall is still here but it's underif (false)branch, we just can't properly fold that never-taken branch in Tier0 (needs forward sub in tier0) - not a big deal, at least, it no longer allocates.Some nice jit-diffs numbers locally.