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

[release/6.0] Ensure Max/Min for floating-point on x86/x64 are not handled as commutative #75772

Merged
merged 3 commits into from
Oct 5, 2022

Conversation

tannergooding
Copy link
Member

@tannergooding tannergooding commented Sep 16, 2022

Backport of #75683 to release/6.0

/cc @tannergooding

Customer Impact

Customers utilizing the Sse.Min/Max(float), Sse2.Min/Max(double) or Avx.Min/Max(float/double) intrinsics may get "invalid" codegen that results in an incorrect result being returned if an input is NaN or both inputs are zero (of any sign).

This issue was raised by ImageSharp as it was impacting their ability to update code to target .NET 7. It also exists in .NET 6 and is trivial to hit with a simple refactoring of existing their existing logic.

Testing

Explicit tests were added to cover the impacted scenarios.

Risk

Low. This issue has been in the codebase for at least 5 years and impacts .NET Core 3.1, 5.0, 6.0, and 7.0. Due to other codegen improvements, it is now more likely to be hit in .NET 7.

However, the root cause of the issue is related to an incorrect flag labeling the intrinsics as being commutative and we are effectively removing that flag so the code churn is small and any risk of the change is localized to these intrinsics.

…tative (dotnet#75683)

* Adding a regression test for SixLabors/ImageSharp#2117

* Ensure Max/Min for floating-point on x86/x64 are not handled as commutative

* Applying formatting patch
@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 Sep 16, 2022
@ghost ghost assigned tannergooding Sep 16, 2022
@ghost
Copy link

ghost commented Sep 16, 2022

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

Issue Details

Backport of #75683 to release/7.0-rc2

/cc @tannergooding

Customer Impact

Customers utilizing the Sse.Min/Max(float), Sse2.Min/Max(double) or Avx.Min/Max(float/double) intrinsics may get "invalid" codegen that results in an incorrect result being returned if an input is NaN or both inputs are zero (of any sign).

This issue was raised by ImageSharp as it was impacting their ability to update code to target .NET 7. It also exists in .NET 6 and is trivial to hit with a simple refactoring of existing their existing logic.

Testing

Explicit tests were added to cover the impacted scenarios.

Risk

Low. This issue has been in the codebase for at least 5 years and impacts .NET Core 3.1, 5.0, 6.0, and 7.0. Due to other codegen improvements, it is now more likely to be hit in .NET 7.

However, the root cause of the issue is related to an incorrect flag labeling the intrinsics as being commutative and we are effectively removing that flag so the code churn is small and any risk of the change is localized to these intrinsics.

Author: tannergooding
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@tannergooding tannergooding added the Servicing-consider Issue for next servicing release review label Sep 16, 2022
@tannergooding
Copy link
Member Author

Backported to .NET 6 as well as per the discussion on #75761

CC. @EgorBo

@JulieLeeMSFT
Copy link
Member

Cc @jeffschwMSFT.

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. we will take for consideration in 6.0.x

@jeffschwMSFT jeffschwMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 19, 2022
@jeffschwMSFT jeffschwMSFT added this to the 7.0.0 milestone Sep 19, 2022
@carlossanlop
Copy link
Member

@tannergooding @jeffschwMSFT the milestone is incorrect, this is a 6.0 backport. Is this fix critical for the October release? If yes, then I can merge it, if not, then we will have to wait till next month.

cc @mmitche

@jeffschwMSFT jeffschwMSFT modified the milestones: 7.0.0, 6.0.10 Sep 19, 2022
@jeffschwMSFT
Copy link
Member

Thanks for the correction. I think this aligns with 6.0.11 (right?)

@jeffschwMSFT jeffschwMSFT added this to the 6.0.11 milestone Sep 19, 2022
@carlossanlop
Copy link
Member

Thanks for the correction. I think this aligns with 6.0.11 (right?)

6.0.10 is October and 6.0.11 is November IIRC. @tannergooding what do you think? Is this critical for October or not?

@carlossanlop
Copy link
Member

Talked to @tannergooding via Teams. This can wait for the next release.

Also, this needs no OOB package authoring changes AFAIK, since it's modifying native code.

@carlossanlop
Copy link
Member

Branch is open again. CI is green, approved, signed-off, no OOB package authoring required, ready to merge. :shipit:

@carlossanlop carlossanlop merged commit 4b035c9 into dotnet:release/6.0 Oct 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2022
@tannergooding tannergooding deleted the release/6.0 branch November 11, 2022 15:11
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 Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants