1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-09 09:34:49 +09:00

Don't fold relops with side effects that are used in jumps (#103903)

* Don't fold relops with side effects that are used in jumps

* Reorder comparisons
This commit is contained in:
Tanner Gooding 2024-06-24 14:51:55 -07:00 committed by GitHub
parent b79c57efbf
commit e6a0fd6e7f
Signed by: github
GPG key ID: B5690EEEBB952194
5 changed files with 75 additions and 0 deletions

View file

@ -14299,6 +14299,14 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree)
// Here `op` is the non-constant operand, `cons` is the constant operand
// and `val` is the constant value.
if (((op->gtFlags & GTF_SIDE_EFFECT) != 0) && tree->OperIsCompare() && ((tree->gtFlags & GTF_RELOP_JMP_USED) != 0))
{
// TODO-CQ: Some phases currently have an invariant that JTRUE(x)
// must have x be a relational operator. As such, we cannot currently
// fold such cases and need to preserve the tree as is.
return tree;
}
switch (oper)
{
case GT_LE:

View file

@ -0,0 +1,59 @@
// 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;
using Xunit;
public class Runtime_103888_A
{
// Generated by Fuzzlyn v1.6 on 2024-06-23 16:50:17
// Run on X64 Windows
// Seed: 14337630088129483600
// Reduced from 13.5 KiB to 0.3 KiB in 00:01:04
// Hits JIT assert in Release:
// Assertion failed 'block->bbPreorderNum == preorderNum' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Early Value Propagation' (IL size 47; hash 0xade6b36b; FullOpts)
//
// File: D:\a\_work\1\s\src\coreclr\jit\fgdiagnostic.cpp Line: 4750
//
public class C0
{
public uint F0;
public int F1;
}
[Fact]
public static void TestEntryPoint()
{
C0 vr0 = new C0();
if (!((ulong)(0 << vr0.F1) <= vr0.F0))
{
vr0.F1 ^= vr0.F1;
}
}
}
public class Runtime_103888_B
{
public static ushort[, ] s_69 = new ushort[1,1];
[Fact]
public static void TestEntryPoint()
{
try
{
var vr2 = new int[][, ][]{new int[, ][]{{new int[]{0}}}};
}
finally
{
if (0UL > s_69[0, 0])
{
var vr3 = new byte[, ]{{0}};
}
else
{
uint[, ] vr4 = new uint[, ]{{0}};
}
}
}
}

View file

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>