Skip to content

Improve fgGetStaticFieldSeqAndAddress#78961

Merged
EgorBo merged 4 commits into
dotnet:mainfrom
EgorBo:improve-fgGetStaticFieldSeqAndAddress
Nov 29, 2022
Merged

Improve fgGetStaticFieldSeqAndAddress#78961
EgorBo merged 4 commits into
dotnet:mainfrom
EgorBo:improve-fgGetStaticFieldSeqAndAddress

Conversation

@EgorBo

@EgorBo EgorBo commented Nov 29, 2022

Copy link
Copy Markdown
Member

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
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 29, 2022
@ghost

ghost commented Nov 29, 2022

Copy link
Copy Markdown

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: -

Comment thread 0001-Improve-GetStaticFieldSeqAndAddress.patch Outdated

@TIHan TIHan left a comment

Copy link
Copy Markdown
Contributor

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

EgorBo commented Nov 29, 2022

Copy link
Copy Markdown
Member Author

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

EgorBo commented Nov 29, 2022

Copy link
Copy Markdown
Member Author

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