-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Update the JIT to track Span.Length and ReadOnlySpan.Length as "never negative"
#81055
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
Changes from 4 commits
5dac74f
c88ae01
820a5d8
618226e
e5d4b13
d700615
60ffb5a
2f882d8
c224a3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1392,6 +1392,11 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor> | |
| { | ||
| GenTreeFlags lclVarFlags = node->gtFlags & (GTF_NODE_MASK | GTF_DONT_CSE); | ||
|
|
||
| if (node->OperIs(GT_FIELD) && node->AsField()->IsNeverNegative()) | ||
| { | ||
| m_compiler->lvaGetDesc(fieldLclNum)->SetIsNeverNegative(true); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make any difference in the PMI diffs if we add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a look independently, but I wouldn't expect significant diffs and I don't think we'd want this to be the exclusive way to determine that. -- Posting a rough summary of what got discussed on Discord. In order for user code to access the field, they must go through For the block copy case, you don't really end up with interesting opts possible. The user could then access the copied field, but that would still go through We'd want to keep the flag we set as part of There are other potential opts and tracking we could do, including loop cloning if we had some
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am still not a fan of this propagation of "never negative" from a If we want to keep it this way I think the new accessors/information on My preference would still be to introduce
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm concerned about the additional cost that doing that would bring. What we have here is simple, effectively, extensible, and works without negatively impacting throughput (it's a small sub 0.01% gain on most platforms and a small sub 0.01% regression on a couple). While this wouldn't add overhead to the promotion case since we already call
I think this is reasonable for now. That being said, I think we want and need this to be more generally extensible long term. The concept of a exposing an
Can you elaborate on the fragility and how you think future changes could impact this? Are you referring to locals getting tagged and then reused for something else? Users assigning negative values (which should only be possible via unsafe code)? Or something else?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The overhead would be in the pattern recognition inside There would be no new EE calls since
I am referring to a future JIT dev marking a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talked a bit more on Discord to get clarification. I've updated The plan after this PR is to look into also providing the |
||
| } | ||
|
|
||
| if ((user != nullptr) && user->OperIs(GT_ASG) && (user->AsOp()->gtOp1 == node)) | ||
| { | ||
| lclVarFlags |= GTF_VAR_DEF; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.