-
Notifications
You must be signed in to change notification settings - Fork 5.4k
JIT: Handle some "field offset computation" patterns #81998
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9f755be
JIT: Handle some "field offset computation" patterns
jakobbotsch df73501
Oops
jakobbotsch b07d687
Merge branch 'main' into fold-local-offsets
jakobbotsch 1c4c0ae
Merge branch 'main' of github.com:dotnet/runtime into fold-local-offsets
jakobbotsch 8f9c4f2
Fix wrong identity for overflowing SUBs
jakobbotsch b944901
Handle in local morph instead; revert previous changes
jakobbotsch e1f4777
Handle field-to-field offset
jakobbotsch 4239377
Generalize
jakobbotsch adb3474
Expand assertion to cover TYP_BYREF
jakobbotsch 70627f4
Apply suggestions from code review
jakobbotsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -677,6 +677,34 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor> | |
| PopValue(); | ||
| break; | ||
|
|
||
| case GT_SUB: | ||
| { | ||
| Value& rhs = TopValue(0); | ||
| Value& lhs = TopValue(1); | ||
| if (m_compiler->opts.OptimizationEnabled() && lhs.IsAddress() && rhs.IsAddress() && | ||
| (lhs.LclNum() == rhs.LclNum()) && (rhs.Offset() <= lhs.Offset()) && | ||
| FitsIn<int>(lhs.Offset() - rhs.Offset())) | ||
| { | ||
| // TODO-Correctness: Due to inlining we may end up with incorrectly typed SUB trees here. | ||
| assert(node->TypeIs(TYP_I_IMPL, TYP_BYREF)); | ||
|
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. Opened #84291 for this. |
||
|
|
||
| ssize_t result = (ssize_t)(lhs.Offset() - rhs.Offset()); | ||
| *use = node = m_compiler->gtNewIconNode(result, TYP_I_IMPL); | ||
|
jakobbotsch marked this conversation as resolved.
Outdated
|
||
| INDEBUG(lhs.Consume()); | ||
| INDEBUG(rhs.Consume()); | ||
| PopValue(); | ||
| PopValue(); | ||
| m_stmtModified = true; | ||
| break; | ||
| } | ||
|
|
||
| EscapeValue(TopValue(0), node); | ||
| PopValue(); | ||
| EscapeValue(TopValue(0), node); | ||
| PopValue(); | ||
| break; | ||
| } | ||
|
|
||
| case GT_FIELD_ADDR: | ||
| if (node->AsField()->IsInstance()) | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.