Skip to content

Conversation

@tannergooding
Copy link
Member

This resolves the issue introduced by #102702 which was discovered in #103094 (comment).

The bug was missed in the initial PR as the Arm64 handling for mask <-> vector conversions was a bit different from Xarch, and it wasn't expected to be able to encounter nodes in such a shape.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 11, 2024
@DragosDanielBoia
Copy link
Contributor

@dotnet-policy-service rerun

@kunalspathak
Copy link
Contributor

@dotnet/arm64-contrib FYI

Copy link
Contributor

@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. Thanks for fixing this.


if (varTypeIsMask(operand->TypeGet()))
{
#if defined(FEATURE_HW_INTRINSICS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead wrap the if-condition in #ifdef FEATURE_MASKED_HW_INTRINSICS

Copy link
Member Author

Choose a reason for hiding this comment

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

TYP_MASK and a lot of the surrounding support isn't under that feature switch.

If we were to centralize everything under that feature switch, I think it should be a separate PR. However, I'm also not convinced we need that as we didn't set any such flag up for XARCH.

Copy link
Contributor

Choose a reason for hiding this comment

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

Have a separate PR is fine for me, but do we even see TYP_MASK if it is not FEATURED_HW_INTRINSICS?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe we do today, but that doesn't mean it will never happen. varTypeIsMask returns constant false on unsupported platforms, so this just ensures any future scenarios handle this appropriately and will be optimized out as dead code otherwise.

CorInfoType simdBaseJitType,
unsigned simdSize)
{
assert(varTypeIsMask(type));
Copy link
Contributor

@TIHan TIHan Jun 11, 2024

Choose a reason for hiding this comment

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

Do we need to pass a TYP_MASK for type every time we call gtNewSimdCvtVectorToMaskNode ? Since we only have one TYP_MASK, feels like we could just get rid of this parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's here to support any future expansion desired. For example, it may be important to differentiate mask based on size.

if (!varTypeIsMask(op2))
{
retNode->AsHWIntrinsic()->Op(2) = gtNewSimdCvtVectorToMaskNode(retType, op2, simdBaseJitType, simdSize);
retNode->AsHWIntrinsic()->Op(2) = gtNewSimdCvtVectorToMaskNode(TYP_MASK, op2, simdBaseJitType, simdSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

probably add an assert in gtNewSimdCvtVectorToMaskNode() that type == TYP_MASK?

Copy link
Member Author

Choose a reason for hiding this comment

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

That assert already exists and is what caught the failure.

Copy link
Contributor

@TIHan TIHan left a comment

Choose a reason for hiding this comment

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

LGTM. This will fix the assertions in #103094

@tannergooding tannergooding merged commit 96be3e2 into dotnet:main Jun 12, 2024
@tannergooding tannergooding deleted the rewrite-mask branch June 12, 2024 07:01
@github-actions github-actions bot locked and limited conversation to collaborators Jul 12, 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.

4 participants