-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Optimize "new DateTime(<const args>)" via improvements in JIT VN #81005
Conversation
2) Cache FieldSeq* for addresses
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue DetailsThis PR is the last missing piece to fold All of that code is inlined and folded including "array" accesses to those What this PR does specifically is:
|
@jakobbotsch @SingleAccretion PTAL VN change Diffs, but they don't represent actual changes when something new is folded in RVA, thus, the missing contexts in the Diff. Some size regressions because once I dropped the implicit cast for |
This is Ultra Pro Max amazing! 🎉🎉 |
@SingleAccretion does it look good to you now? |
Co-authored-by: SingleAccretion <[email protected]>
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.
LGTM, I assume the test failures are unrelated. Is there any significant memory impact from the new map?
I wasn't able to detect any significant impact, because initially wanted to make it lazy-allocated but gave up. As for its content then only methods with static fields contribute to that (and we rarely see method with a lot of static field operations inside them). As for JIT TP, I have a small improvement for VN's APIs to get -0.02% back but that will land separately Failures are #80666 |
This PR is the last missing piece to fold
new DateTime(2023, 1, 22)
call into just a constant in JIT. While there is not much value in foldingDateTime
specifically, the PR(s) improves constant folding in JIT around RVA fields for a general case and makes it more robust. Just look at this screenshot (click to zoom):All of that code is inlined and folded including "array" accesses to those
ReadOnlySpan<>
fields during JIT compilation intoTest()
method on the left-top.Previous codegen for
Test()
:What this PR does specifically is:
nint -> byref
operations on top of ICON handles (thanks to @SingleAccretion for idea). This leads to a slight size regression because JIT now recognizes more places it can propagate constants toFieldSeq*
for given address via a side hashmap since we don't encode FieldSeq into a VN.SPMI diffs are expected not to catch some improvements due to new VM calls (contexts) to fold RVAs
Just-for-fun retrospective of PRs helped to fold all of that 🙂:
ROS<>
for truly constant arraysRuntimeHelpers.CreateSpan
API and intrinsified it in JITFieldSeq*
GT_PHI
nodes in VN phase (wouldn't be able to fold).