Skip to content

Conversation

@jakobbotsch
Copy link
Member

TYP_UINT is only meaningful for certain operations in the JIT and nodes
can/should never produce values of this type.

Fix #71360

TYP_UINT is only meaningful for certain operations in the JIT and nodes
can/should never produce values of this type.

Fix dotnet#71360
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 28, 2022
@ghost ghost assigned jakobbotsch Jun 28, 2022
@ghost
Copy link

ghost commented Jun 28, 2022

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

Issue Details

TYP_UINT is only meaningful for certain operations in the JIT and nodes
can/should never produce values of this type.

Fix #71360

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

The logic in LowerArg that normalized small-typed nodes in an ad-hoc manner also seems strange to me. I've changed that to just use genActualType which would have avoided the assert on its own as well.

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @kunalspathak

@jakobbotsch jakobbotsch requested a review from kunalspathak June 28, 2022 15:36
if (varTypeIsSmall(type))
{
// Normalize 'type', it represents the item that we will be storing in the Outgoing Args
type = TYP_INT;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just that I understand, was there an inconsistency in the way we set type here to TYP_INT but not doing the same in ToScalar()?

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 would say the bug is in ToScalar alone, typing a node as TYP_UINT (or TYP_ULONG) is invalid IR. These types are meaningless except for casts (and maybe some SIMD base types).

Under the assumption that we never see TYP_UINT or TYP_ULONG typed nodes this logic here is equivalent to genActualType.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. So is the assert reported in #71360 is the only one that checks for this or do we have other places we make sure that type is never one of TYP_UINT or TYP_ULONG?

Copy link
Member Author

Choose a reason for hiding this comment

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

Most places in the JIT should be dealing with genActualType that would work correctly even for TYP_UINT/TYP_ULONG. I'm not sure if we have good checking in the places that wouldn't work correctly, but it is hard to know which places that would be. One place is IntegralRange::ForNode that would hit an unreachable().

I've added an item to #12121 about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me.

Copy link
Member

Choose a reason for hiding this comment

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

and maybe some SIMD base types

Its most SIMD base types in practice. The SIMD base type should always be the exact type required for the underlying instruction. That includes correctly tracking the sign and size. This is important because there are many SIMD instructions that differ based on size/type and will do the wrong thing otherwise.

It was definitely a bug that the gtType wasn't the right thing, however.

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

@jakobbotsch jakobbotsch merged commit 14f993e into dotnet:main Jun 28, 2022
@jakobbotsch jakobbotsch deleted the fix-71360 branch June 28, 2022 16:39
@ghost ghost locked as resolved and limited conversation to collaborators Jul 29, 2022
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.

Test failure JIT\\HardwareIntrinsics\\General\\Vector128\\Vector128_r\\Vector128_r.cmd

3 participants