-
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
Unsafe.As produces incorrect data with Vectors (in Release) #9334
Comments
Maybe simpler repo https://gist.github.com/benaadams/b3270fe6e33a136893e39a5e32ceedc7
|
With a current checked build your latest repro produces an assert in lsra.cpp:
And the relevant piece of IR is:
|
This has apparently slipped through the cracks. I'll take a look. |
In a mismatched struct assignment, e.g. using Unsafe.As, we need to retain the OBJ(ADDR(lcl)) on the rhs of the assignment. Fix #15237
Seem to still be getting bad results dotnet/corefx#25510 (comment)
public static Quaternion Add(Quaternion value1, Quaternion value2)
{
Vector4 q1 = Unsafe.As<Quaternion, Vector4>(ref value1);
Vector4 q2 = Unsafe.As<Quaternion, Vector4>(ref value2);
Vector4 result = q1 + q2;
return Unsafe.As<Vector4, Quaternion>(ref result);
} public void QuaternionAddTest()
{
Quaternion a = new Quaternion(1.0f, 2.0f, 3.0f, 4.0f);
Quaternion b = new Quaternion(5.0f, 6.0f, 7.0f, 8.0f);
Quaternion expected = new Quaternion(6.0f, 8.0f, 10.0f, 12.0f);
Quaternion actual;
actual = Quaternion.Add(a, b);
Assert.Equal(expected, actual);
} |
Could it be similar to https://github.com/dotnet/coreclr/issues/16210 ? |
@CarolEidt should I open a new issue? |
Yes, I think that would be best. |
Code: https://gist.github.com/benaadams/290f7d5c7b1eb4a97c6854654c7fd6b2
From dotnet/corefx#25510 (comment)
The text was updated successfully, but these errors were encountered: