KEMBAR78
Use the maskBaseType when consuming a mask directly as part of KORTEST by tannergooding · Pull Request #104364 · dotnet/runtime · GitHub
Skip to content

Conversation

@tannergooding
Copy link
Member

This resolves #104317.

The issue had been that we were eliding ConvertMaskToVector without accounting for the fact that there could have been a change of the baseType such as caused by using value.AsInt32(). We normally do take this into account, there was just an existing path in lowering that missed this and which was now being hit due to recent IR improvements.

An example of where this is problematic would be if we had a TYP_LONG mask of 0b10, the ConvertVectorToMask would produce [Zero, AllBitsSet], if that were then consumed by an operation taking a TYP_INT it would see it as [Zero, Zero, AllBitsSet, AllBitsSet]. However, if we consumed it directly as a mask we'd still have 10 when the API would've needed 0b1100 for parity.

However, some of the use sites we can still elide the ConvertMaskToVector, we just need to fixup the consumer to have the right base type. For example, if we're doing op_Equality against Zero or AllBitsSet, then the bitset expected never changes. The same applies for CndSel which is a bitwise operation.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 3, 2024
@dotnet-policy-service
Copy link
Contributor

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

@tannergooding
Copy link
Member Author

/azp run runtime-coreclr libraries-jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tannergooding
Copy link
Member Author

The same issue exists on .NET 8 as well, it's just less likely to be hit due to the general shape that IR takes. The fix for .NET 8 would be fairly similar to this, but not quite the same as there's been some overall significant changes to the logic here.

@tannergooding tannergooding merged commit 2d0dff4 into dotnet:main Jul 4, 2024
@tannergooding tannergooding deleted the fix-104317 branch July 4, 2024 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2024
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.

[libraries-jitstress] System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.Vector512DoubleEqualsNonCanonicalNaNTest fails in CI on win-x64

2 participants