Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/coreclr/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2962,9 +2962,9 @@ class CSE_Heuristic
do
{
/* Process the next node in the list */
GenTree* exp = lst->tslTree;
Statement* stmt = lst->tslStmt;
BasicBlock* blk = lst->tslBlock;
GenTree* const exp = lst->tslTree;
Statement* const stmt = lst->tslStmt;
BasicBlock* const blk = lst->tslBlock;

/* Advance to the next node in the list */
lst = lst->tslNext;
Expand Down Expand Up @@ -3212,9 +3212,9 @@ class CSE_Heuristic
noway_assert(asg->AsOp()->gtOp2 == val);
}

// assign the proper Value Numbers
asg->gtVNPair.SetBoth(ValueNumStore::VNForVoid()); // The GT_ASG node itself is $VN.Void
asg->AsOp()->gtOp1->gtVNPair = val->gtVNPair; // The dest op is the same as 'val'
// Assign the proper Value Numbers.
asg->gtVNPair = ValueNumStore::VNPForVoid(); // The GT_ASG node itself is $VN.Void.
asg->AsOp()->gtOp1->gtVNPair = ValueNumStore::VNPForVoid(); // As is the LHS.

noway_assert(asg->AsOp()->gtOp1->gtOper == GT_LCL_VAR);

Expand Down Expand Up @@ -3263,7 +3263,7 @@ class CSE_Heuristic
cseUse->SetDoNotCSE();
}
}
cseUse->gtVNPair = val->gtVNPair; // The 'cseUse' is equal to 'val'
cseUse->gtVNPair = exp->gtVNPair; // The 'cseUse' is equal to the original expression.

/* Create a comma node for the CSE assignment */
cse = m_pCompiler->gtNewOperNode(GT_COMMA, expTyp, origAsg, cseUse);
Expand Down
40 changes: 40 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_70790/Runtime_70790.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;

public class Runtime_70790
{
private static readonly nint s_intType = typeof(int).TypeHandle.Value;

public static int Main()
{
RuntimeHelpers.RunClassConstructor(typeof(Runtime_70790).TypeHandle);

object a = 1u;
object b = 2u;
if (Problem(a, b))
{
return 101;
}

return 100;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static bool Problem(object a, object b)
{
if (a.GetType() == typeof(int))
{
return true;
}

JitUse(b.GetType() == typeof(int));
JitUse(s_intType - 300);

return false;
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static void JitUse<T>(T arg) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
<!-- Force-enable CSE of constants -->
<CLRTestBatchPreCommands><![CDATA[
$(CLRTestBatchPreCommands)
set DOTNET_JitConstCSE=3
]]></CLRTestBatchPreCommands>
<BashCLRTestPreCommands><![CDATA[
$(BashCLRTestPreCommands)
export DOTNET_JitConstCSE=3
]]></BashCLRTestPreCommands>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>