Skip to content

Remove an unnecessary switch from GenTree:TryGetUse#127632

Merged
tannergooding merged 2 commits intodotnet:mainfrom
tannergooding:gtTryGetUse
May 1, 2026
Merged

Remove an unnecessary switch from GenTree:TryGetUse#127632
tannergooding merged 2 commits intodotnet:mainfrom
tannergooding:gtTryGetUse

Conversation

@tannergooding
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 1, 2026 01:28
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 1, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 refactors GenTree::TryGetUse to avoid a large opcode switch by leveraging existing operator classification helpers (OperIsLeaf, OperIsSpecial, unary/binary handling). As part of enabling that simplification, it reclassifies the ARM64 GT_SELECT_{INC,INV,NEG} nodes to be true conditional/special nodes.

Changes:

  • Reclassify ARM64 GT_SELECT_{INC,INV,NEG} as GenTreeConditional / GTK_SPECIAL (instead of binary GenTreeOp).
  • Add an instance GenTree::OperIsSpecial() convenience helper in gentree.h.
  • Rewrite GenTree::TryGetUse to use leaf/special classification and a unified unary/binary path; remove the TryGetUseBinOp helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/coreclr/jit/gtlist.h Changes GT_SELECT_{INC,INV,NEG} node flavor/kind to be conditional/special.
src/coreclr/jit/gentree.h Adds instance OperIsSpecial(); removes now-unneeded TryGetUseBinOp declaration.
src/coreclr/jit/gentree.cpp Simplifies GenTree::TryGetUse logic and eliminates the dedicated binop helper.

Comment thread src/coreclr/jit/gtlist.h
Comment thread src/coreclr/jit/gtlist.h Outdated
Comment thread src/coreclr/jit/gtlist.h Outdated
@tannergooding tannergooding marked this pull request as ready for review May 1, 2026 03:46
Copilot AI review requested due to automatic review settings May 1, 2026 03:46
@tannergooding
Copy link
Copy Markdown
Member Author

CC. @dotnet/jit-contrib, @EgorBo, @kg for review. Just a simple PR that cleans up GenTree::TryGetUse to use the existing categories.

I found that some of the Arm64 specific conditional nodes were incorrectly tagged as part of this (gtlist and gtstruct didn't agree) and then there was a couple node kinds that were missing from the table so they could've hit the binary path when they shouldn't, so this reduces risk.

Provides a small TP increase as well, more so on LLVM than MSVC:

linux x64
* Overall (-0.02% to -0.00%)
* MinOpts (-0.01% to -0.00%)
* FullOpts (-0.03% to -0.00%)

linux arm64
* Overall (-0.01% to -0.00%)
* FullOpts (-0.01% to -0.00%)

windows x64
* Overall (-0.01% to -0.00%)
* MinOpts (-0.01% to -0.00%)
* FullOpts (-0.01% to -0.00%)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Member

@kg kg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tannergooding tannergooding enabled auto-merge (squash) May 1, 2026 05:16
@tannergooding tannergooding merged commit 9a61dfe into dotnet:main May 1, 2026
135 checks passed
@tannergooding tannergooding deleted the gtTryGetUse branch May 1, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants