-
Couldn't load subscription status.
- Fork 5.2k
JIT: also run local assertion prop in postorder during morph #115626
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
JIT: also run local assertion prop in postorder during morph #115626
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
Nice CQ improvement and TP improvement. Big CQ diffs (both good and bad) seem to be loop cloning related, at least from my limited sample. @dotnet/jit-contrib PTAL |
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.
Pull Request Overview
This PR enables postorder local assertion propagation during morphing to leverage assertions generated in child subtrees when optimizing parent nodes.
- Tracks a new bitvector
apLocalPostorderalongside the existingapLocal. - Integrates a postorder assertion-prop loop in
fgMorphSmpOpguarded by a new config flag. - Updates assertion-kill logic and block/statement initialization to maintain the postorder set.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/jit/morph.cpp | Added apLocalPostorder clear on qmark, integrated postorder assertion-prop loop and diff on kills |
| src/coreclr/jit/jitconfigvalues.h | Introduced JitEnablePostorderLocalAssertionProp config option |
| src/coreclr/jit/compiler.h | Declared new apLocalPostorder bitvector in Compiler class |
Comments suppressed due to low confidence (1)
src/coreclr/jit/morph.cpp:7757
- Consider adding a JIT unit test that enables
JitEnablePostorderLocalAssertionPropand verifies that a pattern likenewarralias + null check is resolved postorder, to prevent regressions.
if (fgGlobalMorph && optLocalAssertionProp && (optAssertionCount > 0))
| Metrics.LocalAssertionOverflow = optAssertionOverflow; | ||
| Metrics.MorphTrackedLocals = lvaTrackedCount; | ||
| Metrics.MorphLocals = lvaCount; | ||
| optLocalAssertionProp = false; |
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.
curious - is this something you noticed or it was prevention from getting into weird state, now that we will do another round of assertions with apLocalPostorder?
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.
I wanted to make sure calls into morph after the global morph phase didn't try and use local assertions. Most uses of local assertions in morph are guarded by fgGlobalMorph but it is easy to forget...
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.
Diffs looks great. Wondering have we investigated why there are some regressions and if there is any pattern out there?
The big regressions seem to be extra loop cloning. I only checked a handful but suspect that's generally the case. |
|
/azp run runtime-coreclr pgostress, runtime-coreclr jitstress, runtime-coreclr gcstress0x3-gcstress0xc |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Optional pipelines have some known failures, so some result screening will be needed. |
|
Stress failures all look like known issues or timeouts. |
Morph currently applies assertions in preorder, so updates made by morph or by local assertion prop to child trees cannot be leveraged when considering parents.
For instance if we had
morph was unable to resolve the branch, despite generating both
V01 != nullandV05 == V01.To address this, keep track of the assertions valid at the end of each statement (via
apLocalPostorder), and use those assertions during morph postorder to try and optimize further. This assertion set is kept up to date with any subsequent kills, and (for simplicity) cleared out if there is a qmark.Note morph can't use the current (
apLocal) assertion set in postorder because morph may also reorder subtrees, so in postorder might end up using assertions generated by (formerly) later-executing subtrees to optimize now earlier-executing subtrees.