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: Fix invalid smnegl transformation #93003

Merged
merged 2 commits into from
Oct 5, 2023
Merged

Conversation

jakobbotsch
Copy link
Member

The newly introduced TryLowerNegToMulLongOp would always lower to a signed multiplication, even for unsigned multiplications.

Also apply a couple of other fixes to the transformation:

  • Replace uses of GenTree::ReplaceWith with LIR::Use::ReplaceWith
  • Add some necessary interference checks

Fix #92537

The newly introduced TryLowerNegToMulLongOp would always lower to a
signed multiplication, even for unsigned multiplications.

Also apply a couple of other fixes to the transformation:
* Replace uses of GenTree::ReplaceWith with LIR::Use::ReplaceWith
* Add some necessary interference checks

Fix dotnet#92537
@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 Oct 4, 2023
@jakobbotsch
Copy link
Member Author

/azp run Fuzzlyn

@ghost ghost assigned jakobbotsch Oct 4, 2023
@ghost
Copy link

ghost commented Oct 4, 2023

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

Issue Details

The newly introduced TryLowerNegToMulLongOp would always lower to a signed multiplication, even for unsigned multiplications.

Also apply a couple of other fixes to the transformation:

  • Replace uses of GenTree::ReplaceWith with LIR::Use::ReplaceWith
  • Add some necessary interference checks

Fix #92537

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines +2836 to +2837
if (!IsInvariantInRange(mul, op))
return nullptr;
Copy link
Member Author

Choose a reason for hiding this comment

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

This interference check is needed, otherwise we will produce bad codegen for a case like

private static long Foo(int a, int b)
{
    return (long)a * (long)b + Bar(ref a);
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static long Bar(ref int x)
{
    x = 0;
    return 0;
}

@kunalspathak
Copy link
Member

The newly introduced TryLowerNegToMulLongOp would always lower to a signed multiplication, even for unsigned multiplications.

I pointed that out in the PR #91886 (comment) but seems like we still missed some cases.

@kunalspathak
Copy link
Member

Interestingly there are no diffs, so seems we don't have coverage for this scenario. Can you please add a test case too?

@jakobbotsch
Copy link
Member Author

Interestingly there are no diffs, so seems we don't have coverage for this scenario. Can you please add a test case too?

Added the test, can you PTAL?

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

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

LGTM

@kunalspathak
Copy link
Member

superpmi failures are known.

@kunalspathak kunalspathak merged commit f555492 into dotnet:main Oct 5, 2023
@jakobbotsch jakobbotsch deleted the fix-92537 branch October 10, 2023 17:31
@ghost ghost locked as resolved and limited conversation to collaborators Nov 9, 2023
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: Invalid smnegl transformation
2 participants