forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: limit phi-refinement to loop-invariant VNs (dotnet#106229)
PhiArg VNs should be invariant in the loop that contains the Phi, otherwise the same VN may refer to values from more than one iteration. Fixes dotnet#105792.
- Loading branch information
1 parent
062667a
commit fc3911e
Showing
3 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/tests/JIT/Regression/JitBlue/Runtime_105792/Runtime_105792.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using Xunit; | ||
|
||
public class Runtime_105792 | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static int Problem1(int x) | ||
{ | ||
int y = 0; | ||
while (x != 0) | ||
{ | ||
if (y == x) return -1; | ||
y = x; | ||
Update(ref x); | ||
} | ||
return x; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static int Problem2(int x) | ||
{ | ||
int y = 0; | ||
while (x != 0) | ||
{ | ||
if (y == x + 1) return -1; | ||
y = x + 1; | ||
Update(ref x); | ||
} | ||
return x; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Update(ref int x) | ||
{ | ||
x = x - 1; | ||
} | ||
|
||
[Fact] | ||
public static int Test1() => Problem1(10) + 100; | ||
|
||
[Fact] | ||
public static int Test2() => Problem2(10) + 100; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/tests/JIT/Regression/JitBlue/Runtime_105792/Runtime_105792.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |