-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix fgValueNumberArrIndexVal for wide reads #58309
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
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsMinimal repro: private static bool Test1()
{
byte[] array = new byte[2];
array[0] = 1;
array[1] = 2;
byte a1 = Unsafe.ReadUnaligned<byte>(ref array[0]);
short a2 = Unsafe.ReadUnaligned<short>(ref array[0]);
array[1] = 42;
short a3 = Unsafe.ReadUnaligned<short>(ref array[0]);
return a1 == a2 && a1 == a3;
}
The fix is quite conservative - it treats such array element loads as "non-proper" and assign a unique VN. PS: Doesn't reproduce on .NET 5.0 /cc @dotnet/jit-contrib
|
|
Heh, so I always wondered if it is possible to make VN use private static float Bitcast()
{
int[] array = new int[2];
array[0] = 1;
return Unsafe.ReadUnaligned<float>(ref Unsafe.As<int, byte>(ref array[0]));
} wholeElem $41 is MapSelect(hAtArrTypeAtArr($340), ind=$142).
VNForCastOper(float) is $42
VNForCast($41, $42) returns $440 {FltCns[1.000000]}
selectedElem is $440 after applying selectors.But that is a separate issue (filed as #58312). |
sandreenko
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
briansull
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.
Looks Good,
|
/backport to release/6.0 |
|
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1185769084 |
Fixes #57914
Minimal repro:
a1,a2anda3all have different values here with the same liberal VN resultingTest1to return true.a1:
a2:
(
$500here is$42with NullRefExc)a3:
The fix is quite conservative - it treats such array element loads as "non-proper" and assign a unique VN.
SuperPMI diffs are empty.
PS: Doesn't reproduce on .NET 5.0
/cc @dotnet/jit-contrib