Cleanup VisitOperandUses and GenTreeVisitor to check common kinds rather than be a big switch - #127972
Merged
Merged
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())
{
tannergooding
marked this pull request as ready for review
May 9, 2026 00:48
EgorBo
approved these changes
May 9, 2026
jakobbotsch
pushed a commit
to jakobbotsch/runtime
that referenced
this pull request
May 12, 2026
…her than be a big switch (dotnet#127972) This should notably reduce risk as well. Some handling had been missed before like `GT_LZCNT` not being handled and hitting the default binary path instead. ### TP impact on Linux x64 ``` linux x64 * Overall (-0.09% to -0.04%) * MinOpts (-0.10% to +0.04%) * FullOpts (-0.11% to -0.04%) ``` ### TP impact on Windows x64 ``` linux arm64 * Overall (-0.21% to -0.15%) * MinOpts (-0.14% to -0.04%) * FullOpts (-0.26% to -0.16%) linux x64 * Overall (-0.23% to -0.15%) * MinOpts (-0.16% to -0.02%) * FullOpts (-0.28% to -0.15%) osx arm64 * Overall (-0.21% to -0.16%) * MinOpts (-0.13% to -0.06%) * FullOpts (-0.22% to -0.16%) windows arm64 * Overall (-0.21% to -0.15%) * MinOpts (-0.14% to -0.04%) * FullOpts (-0.27% to -0.16%) windows x64 * Overall (-0.23% to -0.15%) * MinOpts (-0.16% to -0.02%) * FullOpts (-0.29% to -0.15%) ``` 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.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.