Skip to content

Fixing the new V512 logic to properly negate the mask checks - #89522

Merged
tannergooding merged 3 commits into
dotnet:mainfrom
tannergooding:fix-89512
Jul 27, 2023
Merged

tannergooding merged 3 commits into
dotnet:mainfrom
tannergooding:fix-89512

Conversation

@tannergooding

Copy link
Copy Markdown
Member

This resolves #89512

@ghost ghost added the area-System.Memory label Jul 26, 2023
@ghost ghost assigned tannergooding Jul 26, 2023
@ghost

ghost commented Jul 26, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-memory
See info in area-owners.md if you want to be subscribed.

Issue Details

This resolves #89512

Author: tannergooding
Assignees: -
Labels:

area-System.Memory

Milestone: -

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The root issue for these was that the V128/V256 path was negating the mask. That is, doing effectively NegateIfNeeded(Equals(values, current)) != Zero. Which isn't the same as negating the EqualsAny.

Consider if Equals returned 00 FF 00 00 and so negating that becomes FF 00 FF FF (or vice versa). Neither of these compare equal to Zero and so both return true. While for 00 00 00 00, we get FF FF FF FF (or vice versa). One of these would compare equal to Zero and so would return false.

So, we need the concept of HasMatch where the DontNegate case can do EqualsAny (that is Equals(x, y) != Zero) and the Negate case can do !EqualsAll (that is ~Equals(x, y) != Zero)

@tannergooding
tannergooding marked this pull request as ready for review July 27, 2023 03:23
@tannergooding
tannergooding merged commit 7f13ec5 into dotnet:main Jul 27, 2023
@tannergooding
tannergooding deleted the fix-89512 branch July 27, 2023 17:50
@ghost ghost locked as resolved and limited conversation to collaborators Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MemoryExtensions.IndexOfAnyExcept produces invalid results in AVX-512 enabled hardware

2 participants