Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Add morphing to LE_UN/GT_UN(expr, uint.MaxValue) (dotnet#76525) #113037

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shunkino
Copy link

@shunkino shunkino commented Mar 2, 2025

Add morphing for comparison between uint.MaxValue and a ulong value.

Contribute to: #76525

Add morphing for comparison between uint.MaxValue and a ulong value.
@Copilot Copilot bot review requested due to automatic review settings March 2, 2025 00:09
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 2, 2025

Choose a reason for hiding this comment

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

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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 2, 2025
Copy link
Contributor

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

@shunkino
Copy link
Author

shunkino commented Mar 2, 2025

@dotnet-policy-service agree company="Microsoft"

@@ -8067,6 +8067,8 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
{
tree = fgOptimizeRelationalComparisonWithConst(tree->AsOp());
oper = tree->OperGet();
op1 = tree->gtGetOp1();
op2 = tree->gtGetOp2();
Copy link
Member

Choose a reason for hiding this comment

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

the asserts below this change check exactly that - is it needed?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. The morphing added in this commit is changing gtOp1, so we need to reload ops here just like for fgOptimizeRelationalComparisonWithCasts.

cmp->gtOp1 = shiftNode;

Before this commit, fgOptimizeRelationalComparisonWithConst doesn't update op1 and op2, so there are pair of asserts to check it. Is it better to remove these asserts to clarify this?

                assert(op1 == tree->AsOp()->gtGetOp1());
                assert(op2 == tree->AsOp()->gtGetOp2());

@EgorBo
Copy link
Member

EgorBo commented Mar 2, 2025

Seems like CI failed with

 ISSUE: <ASSERT> #263216 D:\a\_work\1\s\src\coreclr\jit\codegenxarch.cpp (4912) - Assertion failed 'operandReg != REG_RCX' in 'bug.Program:TestEntryPoint():int' during 'Generate code' (IL size 42; hash 0x8feb9733; FullOpts)

GenTreeOp* shiftNode = gtNewOperNode(GT_RSZ, TYP_LONG, op1, icon32);
shiftNode->SetMorphed(this);

cmp->gtOp1 = shiftNode;
Copy link
Member

@EgorBo EgorBo Mar 2, 2025

Choose a reason for hiding this comment

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

EQ/NE(RSZ(expr, 32), 0).

I don't see where that 0 is set here, what is cmp->gtOp2 at this point?

Copy link
Author

Choose a reason for hiding this comment

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

I believe this line sets op2 to 0. All other morphing done in fgOptimizeRelationalComparisonWithConst also don't set 0 explicitly.

op2->SetIntegralValue(0);

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 community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants