Update the assert to correctly check if a tree with value has non-zero destination...
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Fri, 3 Feb 2023 19:50:38 +0000 (11:50 -0800)
committerGitHub <noreply@github.com>
Fri, 3 Feb 2023 19:50:38 +0000 (11:50 -0800)
* Fix the assert

* add test cases

* Remove the unused node

* Revert "Remove the unused node"

This reverts commit 32a8c9c598925133592cb2093cda95c989cc278b.

* fix the test case

* fix the arm64 and arm cases too

src/coreclr/jit/lsraarm.cpp
src/coreclr/jit/lsraarm64.cpp
src/coreclr/jit/lsraxarch.cpp
src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.csproj [new file with mode: 0644]

index 47cdbaa..e360567 100644 (file)
@@ -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;
 }
index f8e5e2f..025d4f5 100644 (file)
@@ -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;
 }
index c0fd603..524bbc8 100644 (file)
@@ -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;
 }
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.cs b/src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.cs
new file mode 100644 (file)
index 0000000..9018ebb
--- /dev/null
@@ -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;
+    }
+}
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_81356/Runtime_81356.csproj
new file mode 100644 (file)
index 0000000..57efc33
--- /dev/null
@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <Optimize>False</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>