-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fixing the codegen for x64 intrinsics to use EA_8BYTE where needed. #23461
Conversation
| HARDWARE_INTRINSIC(SSE_X64_IsSupported, "get_IsSupported", SSE_X64, -1, 0, 0, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_IsSupportedProperty, HW_Flag_NoFlag) | ||
| HARDWARE_INTRINSIC(SSE_X64_ConvertToInt64, "ConvertToInt64", SSE_X64, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cvtss2si, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) | ||
| HARDWARE_INTRINSIC(SSE_X64_ConvertToInt64WithTruncation, "ConvertToInt64WithTruncation", SSE_X64, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cvttss2si, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) | ||
| HARDWARE_INTRINSIC(SSE_X64_ConvertToInt64, "ConvertToInt64", SSE_X64, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cvtss2si, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics|HW_Flag_SpecialCodeGen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: I'm not a fan of doing this via SpecialCodeGen. I'm sure we could do this better via flags or normal checks, but this was the quickest/smallest fix to ensure these were correct.
fiigii
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
@tannergooding - it appears that these intrinsics are covered by the automated tests; is the problem that those tests didn't cover a sufficient range of values? |
CarolEidt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@CarolEidt, kind-of. The RNG for We also don't have anything that guarantees the
|
|
We could probably add a method that gets a |
|
We could do something similar to what I did in VectorConvert.cs: https://github.com/dotnet/coreclr/blob/master/tests/src/JIT/SIMD/VectorConvert.cs#L85. It's a bit clunky, but it starts with a set of corner cases, and then adds random values that are transformed to cover a somewhat broader range. |
If we want to have methods that return a float in a broader range, we should just do: float GetFloat(float minValue, float maxValue)
{
Debug.Assert(!float.IsNaN(minValue) && !float.IsNaN(maxValue));
return Random.Next(BitConverter.SingleToInt32Bits(minValue), BitConverter.SingleToInt32Bits(maxValue));
}As the above will generate a value in the full range given and ensures it is evenly distributed. But realistically, we should probably just add explicit tests for anything where the instruction encoding is dependent on the operand size. Relying on random inputs is just going to be prone to failure as long as those random inputs are actually static due to a fixed seed (as it means testing will never actually expose the failures if they exist). |
I think that's what I was getting at - that we should have a mechanism for including explicit values that exercise the corner/edge cases, with additional "random" values. And I persist in my belief that it is unhelpful to have truly random failures in a test system. Even if the tests spit out their seed value, it is problematic to reproduce these, especially when (as is often the case) one doesn't have all the output from the testing. |
The test generator I setup has most of this available already. The only bad part is it currently requires you to re-declare most of the metadata when you really just want to the value generator field to be an array instead. It probably wouldn't be too difficult to rewrite.
And I still hold that this is mostly an infrastructure problem with the existing tests and could be remedied. But like last time, it's not a hill I'm willing to fight on for the CoreFX/CoreCLR repos and I'm fine with keeping the current mechanism 😄. |
|
I've logged https://github.com/dotnet/coreclr/issues/23465 to track updating the test generation script to support multiple input values so that way metadata duplication can be reduced when adding new edge cases to be tested. |
This resolves https://github.com/dotnet/coreclr/issues/23438
CC. @CarolEidt, @fiigii