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

Fix incorrect VN when folding GT_NEG(GT_MUL(A, C)) #57651

Merged
merged 2 commits into from
Aug 18, 2021

Conversation

jakobbotsch
Copy link
Member

Fixes #57640

cc @dotnet/jit-contrib @SingleAccretion

@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 Aug 18, 2021
@ghost
Copy link

ghost commented Aug 18, 2021

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

Issue Details

Fixes #57640

cc @dotnet/jit-contrib @SingleAccretion

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Aug 18, 2021

I guess it has to be back ported to 6.0 branch

@jakobbotsch
Copy link
Member Author

I guess it has to be back ported to 6.0 branch

Yep, I'll do it once this makes it through CI

@@ -13177,6 +13177,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
GenTree* newOp2 = gtNewIconNode(-constVal, op1op2->TypeGet()); // -C
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we also want to update the VN for the new constant (this is what we do in other places). But since we haven't actually found a bug with it (yet), and the way to do it is kinda verbose right now, and I will be PRing changes that will make it less verbose soon, and the fact that this PR is likely to be backported, I think it is fine to leave this as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, this ends up as a constant without any VN, but my impression was that we handle this ok downstream.

Copy link
Contributor

Choose a reason for hiding this comment

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

I similarly haven't seen places in the optimizer that would trip up on a NoVN constant tree. I would not be surprised if they exist though, these contracts on what should and should not be maintained are very implicit.

@EgorBo
Copy link
Member

EgorBo commented Aug 18, 2021

@jakobbotsch can you please do the same with https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/morph.cpp#L11175-L11189 or ideally somehow unify it with NEG(MUL(A,C)) opt

@EgorBo
Copy link
Member

EgorBo commented Aug 18, 2021

@jakobbotsch
Copy link
Member Author

@EgorBo I don't think those have the problem since they don't return a sub tree.

@EgorBo
Copy link
Member

EgorBo commented Aug 18, 2021

@EgorBo I don't think those have the problem since they don't return a sub tree.

ah, right, nvm, in case of MUL(NEG(X), CNS) VN for MUL remains the same after opt correctly

Copy link
Contributor

@echesakov echesakov left a comment

Choose a reason for hiding this comment

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

LGTM

@jakobbotsch
Copy link
Member Author

CI failures look like #57620

@jakobbotsch jakobbotsch merged commit ec305c7 into dotnet:main Aug 18, 2021
@jakobbotsch jakobbotsch deleted the fix-57640 branch August 18, 2021 20:04
@jakobbotsch
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1144500550

@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Aug 18, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 17, 2021
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 negated result
5 participants