Skip to content

Update fgMorphSmpOp to canonicalize commutative and compare ops at the start of POST-ORDER#127661

Draft
tannergooding wants to merge 7 commits intodotnet:mainfrom
tannergooding:fgMorphSmpOp
Draft

Update fgMorphSmpOp to canonicalize commutative and compare ops at the start of POST-ORDER#127661
tannergooding wants to merge 7 commits intodotnet:mainfrom
tannergooding:fgMorphSmpOp

Conversation

@tannergooding
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 1, 2026 20:09
@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 adjusts CoreCLR JIT morphing to canonicalize operand ordering for commutative operators and comparisons at the start of fgMorphSmpOp post-order processing, improving consistency and enabling post-order optimizations that rely on constants being placed predictably.

Changes:

  • Canonicalize commutative and comparison trees in fgMorphSmpOp post-order by swapping when the left operand is a constant (and swapping relops as needed).
  • Move the ((a % pow2) ==/!= 0) => (a & (pow2-1) ==/!= 0) pattern optimization from pre-order into the GT_EQ/GT_NE post-order handling.
  • Strengthen/debug-guard morphing assumptions by asserting fgMorphTree is not invoked during the value-number CSE phase.

Copilot AI review requested due to automatic review settings May 1, 2026 20:48
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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/jit/morph.cpp Outdated
Comment thread src/coreclr/jit/morph.cpp Outdated
Comment thread src/coreclr/jit/morph.cpp Outdated
Copilot AI review requested due to automatic review settings May 1, 2026 23:50
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings May 2, 2026 01:50
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 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/coreclr/jit/morph.cpp Outdated
Comment thread src/coreclr/jit/morph.cpp Outdated
Comment thread src/coreclr/jit/morph.cpp Outdated
Copilot AI review requested due to automatic review settings May 2, 2026 04:18
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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/jit/morph.cpp

if (tree->OperIsCompare())
{
tree->gtOper = GenTree::SwapRelop(tree->gtOper);
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