Skip to content

Commit 5aeb4f3

Browse files
[release/6.0] Fix incorrect VN when folding GT_NEG(GT_MUL(A, C)) (#57686)
* Fix incorrect VN when folding GT_NEG(GT_MUL(A, C)) Fixes #57640 * Fix test name Co-authored-by: Jakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
1 parent 5d0820a commit 5aeb4f3

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/coreclr/jit/morph.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13177,6 +13177,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
1317713177
GenTree* newOp2 = gtNewIconNode(-constVal, op1op2->TypeGet()); // -C
1317813178
mulOrDiv->gtOp1 = newOp1;
1317913179
mulOrDiv->gtOp2 = newOp2;
13180+
mulOrDiv->SetVNsFromNode(tree);
1318013181

1318113182
DEBUG_DESTROY_NODE(tree);
1318213183
DEBUG_DESTROY_NODE(op1op2);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
// Generated by Fuzzlyn v1.2 on 2021-08-15 23:15:19
5+
// Run on .NET 6.0.0-dev on Arm Linux
6+
// Seed: 18219619158927602726
7+
// Reduced from 82.6 KiB to 0.3 KiB in 00:02:54
8+
// Debug: Outputs 14270
9+
// Release: Outputs 4294953026
10+
public class Runtime_57640
11+
{
12+
static long[] s_28 = new long[]{1};
13+
public static int Main()
14+
{
15+
bool correct = true;
16+
var vr10 = s_28[0];
17+
for (int vr13 = 0; vr13 < 2; vr13++)
18+
{
19+
uint vr12 = (uint)(0 - (-14270 * vr10));
20+
correct &= vr12 == 14270;
21+
}
22+
23+
return correct ? 100 : -1;
24+
}
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
<PropertyGroup>
6+
<DebugType>None</DebugType>
7+
<Optimize>True</Optimize>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Include="$(MSBuildProjectName).cs" />
11+
</ItemGroup>
12+
</Project>

0 commit comments

Comments
 (0)