-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
JIT assert if a retyped simd32 is CSE'd and needs to have the upper half saved/restored #35620
Comments
CC. @briansull, @CarolEidt, @echesakovMSFT |
@tannergooding wrote in #35899:
|
We now have a |
@CarolEidt, is there anything preventing us from querying the VM for a proper handle? It would be a one time cost (given we cache the handle) and would only occur for scenarios where we've reinterpret casted the bits. |
@tannergooding Do you know if #50832 has fixed the issue? |
I don't believe #50832 addressed this. |
@briansull PTAL. |
Relevant Comment from #35421 This looks to be exposing an existing bug in CSE for GT_SIMD and GT_HWINTRINSIC. Namely, in optcse we can't always propagate the class handle: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/jit/optcse.cpp#L2649 and so when we eventually get to LinearScan::insertUpperVectorSave, we can have a TYP_UNDEF for lvBaseType: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/jit/lsra.cpp#L6756 which causes genSIMD to then assert. This particular "bug" isn't one in practice because saving/restoring handles the TYP_SIMD32 completely opaquely and ignores the underlying type: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/jit/simdcodegenxarch.cpp#L641 However, if you retype a vector (from ushort to short for example) then this could surface in any number of ways ultimately resulting in a similar issue for anything using lvBaseType In the case of GT_SIMD it was producing:
And you can see that the |, eq, init, and gt all use base types different from the original input (ushort) While for the new code:
We are doing it for CompareLessThan and Subtract. We ultimately have to be able to retype as certain operations only exist for certain types on some platforms (e.g. CompareGreaterThan on integrals for x86 is only for signed, so we have to adjust the inputs for unsigned). |
This other comment in #35899 is also relevant:
|
It doesn't seem to me to be a good time to introduce a change like this, without an active bug that is being fixed by this code change. As the original issue that this issue dealt with was fixed by #35899 We should either close this issue or move it to 7.0 @tannergooding What do you think? |
I think it should be moved to 7 as I agree that it doesn't represent a known issue today. However, I don't think it should be closed as we will ideally fix the handling of these to avoid any downstream issues or performance gaps caused by retyping. |
Moving to .NET 7. |
@tannergooding Might this one have been fixed by #38484? |
ping @tannergooding |
Just reading the issue vs PR description I wouldn't expect it. This issue is around a retyped I'd expect this issue to be caused by a |
I was basing that on your original description which is:
Those links are broken but pointed to the relevant code that @sandreenko changed in #38484, where he made CSE always propagate the class handle. |
Ah, it might've fixed it then if that PR causes the handle to always be available. I think more generally we probably want LSRA to not be dependent on the class handle. The underlying type of a |
As per #35421 (comment), it is possible for the
genSIMDIntrinsic
to assert for anyGT_SIMD
orGT_HWINTRINSIC
which has been retyped if the target type hasn't been actually encountered (and therefore is missing from the SIMD handle cache).At least at initial glance, it could likely be resolved by setting
lvBaseType
based on thetree->gtSimdBaseType
from theGT_SIMD
orGT_HWINTRINSIC
(whethertree
is one directly or indirectly viaGT_IND
,GT_OBJ
, orGT_ADDR
).category:correctness
theme:hardware-intrinsics
skill-level:intermediate
cost:medium
The text was updated successfully, but these errors were encountered: