-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[RyuJIT] Track exact class for special intrinsics (EqulityComparer, Comparer) #48279
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
|
Can we eliminate code duplication like: runtime/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs Lines 531 to 611 in 65b923a
with this? |
It would need to hoist resolving the comparer in a shared generic (where it can't devirtualize) and devirtualize in-place for a non-shared generic to work there? #10050 |
Unfortunately while my fix indeed tells JIT that a local is of an exact type (thus, it can devirtualize calls with it) - it still introduces a static initialization ( I'm taking a look if I can improve this behavior in my PR so we can drop that workaround. |
|
Going to leave it as is for now. In order to eliminate that redundant static initialization in case of methods-with-loops more changes are required: We need to make sure |
|
@dotnet/jit-contrib PTAL |
|
Can you run diffs? |
|
Also add the test case from #10500 and look at diffs (thought I had added it, but looks like I didn't...) |
Size regressions/improvements because of inlining (some Equal/Compare implementations lead to size improvements after inlining, e.g. Byte.CompareTo) |
@AndyAyersMS Are you sure that is a correct link? |
|
Try #10050. |
AndyAyersMS
left a comment
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.
Changes look good.
Are you going to follow up by trying to enable the special DCE? If so, maybe open a new issue..?
Yes, will open a new issue for that in a moment. |
|
Did you get a chance to look at the impact of this change on the test you added (the one from #10050)? How far are we from properly handling the cases there? |
Yes, here the diff for all methods inside that test assembly: https://www.diffchecker.com/0QNbzcdW (left - master, right - this PR)
|
Fixes #48273 (comment) (cc @drieseng, @stephentoub)
Now jit should be able to track exact class for these special intrinsics (EqulityComparer and Comparer) for locals (single-def ones), e.g.:
Codegen diff: https://www.diffchecker.com/GAPNhiJs (this PR is on the right)
CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASSis still there in cases of locals though.