Skip to content
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

Improve fgGetStaticFieldSeqAndAddress #78961

Merged
merged 4 commits into from
Nov 29, 2022

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Nov 29, 2022

It turns out it's a bit too conservative by looking only at CNS_INT nodes and in a case I found I need to rely on VN instead, e.g.:

[000106] U--XG------                         \--*  IND       long   <l:$280, c:$281>
[000027] -------N---                            \--*  ADD       long   $141
[000026] ---------U-                               +--*  CAST      long <- ulong <- uint $100
[000025] -----------                               |  \--*  LSH       int    $46
[000098] -----------                               |     +--*  XOR       int    $44
[000097] -----------                               |     |  +--*  HWINTRINSIC int     LeadingZeroCount $42
[000096] -----------                               |     |  |  \--*  CNS_INT   int    445 $41
[000095] -----------                               |     |  \--*  CNS_INT   int    31 $43
[000024] -----------                               |     \--*  CNS_INT   int    3 $45
[000132] H----------                               \--*  CNS_INT(h) long   0x1b1b6542c18 static Fseq[..] $140

In this case CAST node has $100,$100 VN that represents an integer constant (with help of #78929)

@dotnet/jit-contrib PTAL simple change.

@ghost ghost assigned EgorBo Nov 29, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 29, 2022
@ghost
Copy link

ghost commented Nov 29, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

It turns out it's a bit too conservative by looking only at CNS_INT nodes and in a case I found I need to rely on VN instead, e.g.:

[000106] U--XG------                         \--*  IND       long   <l:$280, c:$281>
[000027] -------N---                            \--*  ADD       long   $141
[000026] ---------U-                               +--*  CAST      long <- ulong <- uint $100
[000025] -----------                               |  \--*  LSH       int    $46
[000098] -----------                               |     +--*  XOR       int    $44
[000097] -----------                               |     |  +--*  HWINTRINSIC int     LeadingZeroCount $42
[000096] -----------                               |     |  |  \--*  CNS_INT   int    445 $41
[000095] -----------                               |     |  \--*  CNS_INT   int    31 $43
[000024] -----------                               |     \--*  CNS_INT   int    3 $45
[000132] H----------                               \--*  CNS_INT(h) long   0x1b1b6542c18 static Fseq[..] $140

In this case CAST node has $100,$100 VN that represents an integer constant (with help of #78929)

@dotnet/jit-contrib PTAL simple change.

Author: EgorBo
Assignees: EgorBo
Labels:

area-CodeGen-coreclr

Milestone: -

Copy link
Contributor

@TIHan TIHan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a simple and good change to me, pending CI.

Quick question, what is GTF_ICON_STATIC_HDL and why are we not including them?

@EgorBo
Copy link
Member Author

EgorBo commented Nov 29, 2022

GTF_ICON_STATIC_HDL

This functions looks for trees where GTF_ICON_STATIC_HDL (address of a static field basically, in this case -- address of an RVA element) is blended with constant offsets, e.g.
ADD(ICON_STATIC, 10) or ADD(ADD(ICON_STATIC, 10), LCL) where LCL has "I am a constant" VN

@EgorBo
Copy link
Member Author

EgorBo commented Nov 29, 2022

Failure is #78986 (fixed)

@EgorBo EgorBo merged commit 4887843 into dotnet:main Nov 29, 2022
@EgorBo EgorBo deleted the improve-fgGetStaticFieldSeqAndAddress branch November 29, 2022 21:51
@ghost ghost locked as resolved and limited conversation to collaborators Dec 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants