Fix fgValueNumberArrIndexVal for wide reads#58309
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). |
|
/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