Cleanup VisitOperandUses and GenTreeVisitor to check common kinds rather than be a big switch#127972
Open
tannergooding wants to merge 4 commits intodotnet:mainfrom
Open
Cleanup VisitOperandUses and GenTreeVisitor to check common kinds rather than be a big switch#127972tannergooding wants to merge 4 commits intodotnet:mainfrom
tannergooding wants to merge 4 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors GenTree::VisitOperandUses to use OperIsLeaf / OperIsBinary / OperIsUnary fast-path checks instead of an explicit per-op switch, leaving only GTK_SPECIAL nodes handled in a smaller switch.
Changes:
- Replace the large
OperGet()switch with kind-based checks (leaf/binary/unary/special) inVisitOperandUses. - Centralize operand walking for most nodes via
AsOp()/AsUnOp()handling. - Keep explicit operand iteration for special-structure nodes (e.g., call args, phi uses, field list, cmpxchg, arr elem).
Comments suppressed due to low confidence (1)
src/coreclr/jit/compiler.hpp:4438
OperIsSpecial()includes ARM64 conditional nodesGT_SELECT_INC,GT_SELECT_INV, andGT_SELECT_NEG(seegtlist.h), but theOperGet()switch here only handlesGT_SELECT. As a result,VisitOperandUseswill hit the default case for these nodes and skip visiting their operands (andGT_SELECT_*can have an optionalgtOp2that still needs visiting when present). Please add explicit cases forGT_SELECT_INC/INV/NEG(and handle their optionalgtOp2), so operand walking remains correct on ARM64.
assert(OperIsSpecial());
switch (OperGet())
{
#if defined(FEATURE_HW_INTRINSICS)
case GT_HWINTRINSIC:
for (GenTree** use : this->AsMultiOp()->UseEdges())
{
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should notably reduce risk as well. Some handling had been missed before like
GT_LZCNTnot being handled and hitting the default binary path instead.TP impact on Linux x64
TP impact on Windows x64
Windows x86 has a TP hit, from
-0.00% to +0.06%for MinOpts, but that should be fine given the wins we see elsewhere and the improved robustness for the visitors when new node kinds are introduced.