Skip to content

JIT: fix arm64 issue around flags and neg with contained operand #113391

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

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

AndyAyersMS
Copy link
Member

If neg has a contained operand (mul) it cannot set flags.

Fixes #113320

If `neg` has a contained operand (`mul`) it cannot set flags.

Fixes dotnet#113320
@Copilot Copilot AI review requested due to automatic review settings March 11, 2025 20:58
@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 11, 2025
Copy link
Contributor

@Copilot 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 introduces a regression test to verify the JIT fix addressing an arm64 issue where a neg instruction with a contained operand (mul) cannot set flags.

  • Adds a new test file to capture the faulty behavior
  • Verifies JIT behavior on Arm64 in both Debug and Release builds

@AndyAyersMS
Copy link
Member Author

Also fixes issue I ran into in #112998.

@dotnet/jit-contrib PTAL

{
return true;
}

// We do not support setting zero flag for madd/msub.
if (OperIs(GT_NEG) && (!gtGetOp1()->OperIs(GT_MUL) || !gtGetOp1()->isContained()))
Copy link
Member

@EgorBo EgorBo Mar 11, 2025

Choose a reason for hiding this comment

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

I presume just if (OperIs(GT_NEG) && !gtGetOp1()->isContained()) would be enough since NEG can't contain anything. Also, we should've had a separate node type for MUL+ADD/SUB (likely my fault)

@@ -19978,17 +19978,21 @@ bool GenTree::SupportsSettingZeroFlag()
}
#endif
#elif defined(TARGET_ARM64)
if (OperIs(GT_AND, GT_AND_NOT, GT_NEG))
if (OperIs(GT_AND, GT_AND_NOT))
{
return true;
}

// We do not support setting zero flag for madd/msub.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// We do not support setting zero flag for madd/msub.
// We do not support setting zero flag for mneg/madd/msub.

feel free to skip to avoid CI rerun...

@AndyAyersMS AndyAyersMS merged commit ded5f59 into dotnet:main Mar 12, 2025
119 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

JIT: Bad result with modulo on linux-arm64
4 participants