-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: Avoid reordering operands in fgMorphModToSubMulDiv (#71615)
* JIT: Avoid reordering operands in fgMorphModToSubMulDiv fgMorphModToSubMulDiv tries to check if it is ok to "clone" locals instead of spilling them by checking for address exposure. This was necessary because GTF_GLOB_REF is not up-to-date in preorder during morph, which is when this runs. However, address exposure is not valid for implicit byrefs at this point, so the check is not enough. The logic is trying to figure out which of the operands need to be spilled and which of them can be cloned. However, the logic was also wrong in the face of potential embedded assignments. Thus, rework it to be a bit more conservative but correct. As part of this, remove fgIsSafeToClone and make fgMakeMultiUse less conservative by avoiding checking for address exposure. This was probably an attempt at some limited interference checks, but from what I could see other uses do not need this. Fix #65118 * Add a test * Revert unnecessary change * Switch to gtCloneExpr
- Loading branch information
1 parent
a33b9d8
commit ffcb014
Showing
4 changed files
with
99 additions
and
43 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
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
58 changes: 58 additions & 0 deletions
58
src/tests/JIT/Regression/JitBlue/Runtime_71600/Runtime_71600.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,58 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// Generated by Fuzzlyn v1.5 on 2022-07-03 14:40:52 | ||
// Run on Arm64 MacOS | ||
// Seed: 5960657379714964908 | ||
// Reduced from 328.5 KiB to 0.8 KiB in 00:02:08 | ||
// Debug: Outputs 0 | ||
// Release: Outputs 1 | ||
using System.Runtime.CompilerServices; | ||
|
||
public struct S0 | ||
{ | ||
public long F0; | ||
public long F1; | ||
public S0(long f1): this() | ||
{ | ||
F1 = f1; | ||
} | ||
} | ||
|
||
public struct S1 | ||
{ | ||
public uint F1; | ||
public ushort F2; | ||
public S0 F4; | ||
public S1(ulong f5): this() | ||
{ | ||
} | ||
|
||
public long M82(ref short[] arg0) | ||
{ | ||
Runtime_71600.s_13 = this.F1++; | ||
S1 var1 = new S1(0); | ||
return Runtime_71600.s_39[0].F1; | ||
} | ||
} | ||
|
||
public class Runtime_71600 | ||
{ | ||
public static uint s_13; | ||
public static short[] s_28; | ||
public static S0[] s_39; | ||
public static int Main() | ||
{ | ||
S0[] vr2 = new S0[]{new S0(-1)}; | ||
s_39 = vr2; | ||
S1 vr3 = default(S1); | ||
return M80(vr3) == 0 ? 100 : -1; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static int M80(S1 arg0) | ||
{ | ||
arg0.F2 += (ushort)(arg0.F1 % (uint)arg0.M82(ref s_28)); | ||
return arg0.F2; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_71600/Runtime_71600.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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |