-
Notifications
You must be signed in to change notification settings - Fork 5.1k
JIT: retype more ints during constant prop #116759
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
Conversation
In particular be willing to retype constant static field handles as TYP_BYREF. Closes dotnet#116655.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
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 refines constant propagation for integer constants by allowing static field handles and certain object handles to be retyped to reference types under more conditions, removing the old propagateType
flag.
- Simplified relocation checks to permit only non-zero static handles with
compReloc
enabled. - Updated object-handle propagation to reject non-
TYP_REF
trees and always applyChangeType
. - Removed the
propagateType
flag and hoisted theChangeType
call outside conditionals.
Comments suppressed due to low confidence (2)
src/coreclr/jit/assertionprop.cpp:3238
- This new branch rejects object handles when the tree isn't
TYP_REF
; consider adding a unit test to cover both accepting and rejecting paths forGTF_ICON_OBJ_HDL
under different tree types.
if (!newTree->IsIntegralConst(0) && newTree->IsIconHandle(GTF_ICON_OBJ_HDL) && !tree->TypeIs(TYP_REF))
src/coreclr/jit/assertionprop.cpp:3245
- The
ChangeType
call is now unconditional for allO2K_CONST_INT
cases, but originally it only applied whenpropagateType
was true. Consider reinstating a guard so that only intended handle constants actually get retyped.
newTree->ChangeType(tree->TypeGet());
@@ -3212,14 +3211,10 @@ GenTree* Compiler::optConstantAssertionProp(AssertionDsc* curAssertion, | |||
|
|||
case O2K_CONST_INT: | |||
|
|||
// Don't propagate handles if we need to report relocs. | |||
if (opts.compReloc && curAssertion->op2.HasIconFlag() && curAssertion->op2.u1.iconVal != 0) | |||
// Don't propagate non-nulll non-static handles if we need to report relocs. |
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.
There's a typo in the comment: change "non-nulll" to "non-null".
// Don't propagate non-nulll non-static handles if we need to report relocs. | |
// Don't propagate non-null non-static handles if we need to report relocs. |
Copilot uses AI. Check for mistakes.
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.
Will fix this in a subsequent PR
@dotnet/jit-contrib PTAL Some diffs, mainly around different CSE patterns for constants. Possibly we should make CSE of constant handles more type blind and conform to uses or something. |
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
In particular be willing to retype constant static field handles as TYP_BYREF.
Closes #116655.