Skip to content

Commit

Permalink
Update the assert to correctly check if a tree with value has non-zer…
Browse files Browse the repository at this point in the history
…o destination registers (#81412)

* Fix the assert

* add test cases

* Remove the unused node

* Revert "Remove the unused node"

This reverts commit 32a8c9c.

* fix the test case

* fix the arm64 and arm cases too
  • Loading branch information
kunalspathak authored Feb 3, 2023
1 parent dfb9604 commit 3ced968
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/jit/lsraarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ int LinearScan::BuildNode(GenTree* tree)
// We need to be sure that we've set srcCount and dstCount appropriately
assert((dstCount < 2) || tree->IsMultiRegNode());
assert(isLocalDefUse == (tree->IsValue() && tree->IsUnusedValue()));
assert(!tree->IsUnusedValue() || (dstCount != 0));
assert(!tree->IsValue() || (dstCount != 0));
assert(dstCount == tree->GetRegisterDstCount(compiler));
return srcCount;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lsraarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ int LinearScan::BuildNode(GenTree* tree)
// We need to be sure that we've set srcCount and dstCount appropriately
assert((dstCount < 2) || tree->IsMultiRegNode());
assert(isLocalDefUse == (tree->IsValue() && tree->IsUnusedValue()));
assert(!tree->IsUnusedValue() || (dstCount != 0));
assert(!tree->IsValue() || (dstCount != 0));
assert(dstCount == tree->GetRegisterDstCount(compiler));
return srcCount;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lsraxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ int LinearScan::BuildNode(GenTree* tree)
// Not that for XARCH, the maximum number of registers defined is 2.
assert((dstCount < 2) || ((dstCount == 2) && tree->IsMultiRegNode()));
assert(isLocalDefUse == (tree->IsValue() && tree->IsUnusedValue()));
assert(!tree->IsUnusedValue() || (dstCount != 0));
assert(!tree->IsValue() || (dstCount != 0));
assert(dstCount == tree->GetRegisterDstCount(compiler));
return srcCount;
}
Expand Down
17 changes: 17 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

public class Runtime_81356
{
public static byte[] s_130;
public static int Main()
{
try
{
ulong vr5 = default(ulong);
byte vr4 = (byte)(((byte)vr5 & 0) * s_130[0]);
}
catch { }
return 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 3ced968

Please sign in to comment.