未验证 提交 30379b71 编写于 作者: S SingleAccretion 提交者: GitHub

Assign proper VNs to "shared constant" CSE defs (#70852)

* Assign proper VNs to shared CSE defs

They must be those of the original expression, not the "base" constant CSE creates.

* Add a test
上级 3b2883b0
......@@ -2962,9 +2962,9 @@ public:
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;
......@@ -3212,9 +3212,9 @@ public:
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);
......@@ -3263,7 +3263,7 @@ public:
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);
......
// 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) { }
}
<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>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册