Skip to content

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

Merged
tannergooding merged 7 commits into
dotnet:mainfrom
tannergooding:fgMorphSmpOp
May 2, 2026
Merged

Update fgMorphSmpOp to canonicalize commutative and compare ops at the start of POST-ORDER#127661
tannergooding merged 7 commits into
dotnet: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
@tannergooding tannergooding marked this pull request as ready for review May 2, 2026 05:59
@tannergooding
Copy link
Copy Markdown
Member Author

@EgorBo, this should be ready now. There's a few regressions where folding looks to stop happening. It needs to be investigated, but I don't think we should block on it. There's likely some other places that aren't looking for or handling the right edges.

Comment thread src/coreclr/jit/morph.cpp
Comment thread src/coreclr/jit/morph.cpp
Comment thread src/coreclr/jit/morph.cpp
@EgorBo
Copy link
Copy Markdown
Member

EgorBo commented May 2, 2026

There's a few regressions

any idea why osx-arm64 seems to be a pure regression?

@tannergooding
Copy link
Copy Markdown
Member Author

any idea why osx-arm64 seems to be a pure regression?

It has more opts being done, in part because it has a higher ISA baseline.

@tannergooding tannergooding merged commit 805d59a into dotnet:main May 2, 2026
135 checks passed
@tannergooding tannergooding deleted the fgMorphSmpOp branch May 2, 2026 21:34
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