mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 10:00:57 +09:00
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
This commit is contained in:
parent
3b2883b097
commit
30379b718d
3 changed files with 65 additions and 7 deletions
|
@ -2962,9 +2962,9 @@ public:
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Process the next node in the list */
|
/* Process the next node in the list */
|
||||||
GenTree* exp = lst->tslTree;
|
GenTree* const exp = lst->tslTree;
|
||||||
Statement* stmt = lst->tslStmt;
|
Statement* const stmt = lst->tslStmt;
|
||||||
BasicBlock* blk = lst->tslBlock;
|
BasicBlock* const blk = lst->tslBlock;
|
||||||
|
|
||||||
/* Advance to the next node in the list */
|
/* Advance to the next node in the list */
|
||||||
lst = lst->tslNext;
|
lst = lst->tslNext;
|
||||||
|
@ -3212,9 +3212,9 @@ public:
|
||||||
noway_assert(asg->AsOp()->gtOp2 == val);
|
noway_assert(asg->AsOp()->gtOp2 == val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign the proper Value Numbers
|
// Assign the proper Value Numbers.
|
||||||
asg->gtVNPair.SetBoth(ValueNumStore::VNForVoid()); // The GT_ASG node itself is $VN.Void
|
asg->gtVNPair = ValueNumStore::VNPForVoid(); // The GT_ASG node itself is $VN.Void.
|
||||||
asg->AsOp()->gtOp1->gtVNPair = val->gtVNPair; // The dest op is the same as 'val'
|
asg->AsOp()->gtOp1->gtVNPair = ValueNumStore::VNPForVoid(); // As is the LHS.
|
||||||
|
|
||||||
noway_assert(asg->AsOp()->gtOp1->gtOper == GT_LCL_VAR);
|
noway_assert(asg->AsOp()->gtOp1->gtOper == GT_LCL_VAR);
|
||||||
|
|
||||||
|
@ -3263,7 +3263,7 @@ public:
|
||||||
cseUse->SetDoNotCSE();
|
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 */
|
/* Create a comma node for the CSE assignment */
|
||||||
cse = m_pCompiler->gtNewOperNode(GT_COMMA, expTyp, origAsg, cseUse);
|
cse = m_pCompiler->gtNewOperNode(GT_COMMA, expTyp, origAsg, cseUse);
|
||||||
|
|
|
@ -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) { }
|
||||||
|
}
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue