Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7299,15 +7299,17 @@ void Compiler::impImportBlockCode(BasicBlock* block)
// fall through

COND_JUMP:

{
/* Fold comparison if we can */

op1 = gtFoldExpr(op1);

/* Try to fold the really simple cases like 'iconst *, ifne/ifeq'*/
/* Don't make any blocks unreachable in import only mode */

if (op1->gtOper == GT_CNS_INT)
GenTree* effectiveOp1 = op1->gtEffectiveVal();

if (effectiveOp1->OperIs(GT_CNS_INT))
{
/* gtFoldExpr() should prevent this as we don't want to make any blocks
unreachable under compDbgCode */
Expand All @@ -7319,7 +7321,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)

if (block->KindIs(BBJ_COND))
{
bool const isCondTrue = op1->AsIntCon()->gtIconVal != 0;
bool const isCondTrue = effectiveOp1->AsIntCon()->gtIconVal != 0;
FlowEdge* const removedEdge = isCondTrue ? block->GetFalseEdge() : block->GetTrueEdge();
FlowEdge* const retainedEdge = isCondTrue ? block->GetTrueEdge() : block->GetFalseEdge();

Expand Down Expand Up @@ -7403,6 +7405,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
}

goto SPILL_APPEND;
}

case CEE_CEQ:
oper = GT_EQ;
Expand Down
33 changes: 33 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_103600/Runtime_103600.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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;

// Generated by Fuzzlyn v1.6 on 2024-06-16 15:10:23
// Run on X64 Windows
// Seed: 6886681321438315426
// Reduced from 30.1 KiB to 0.3 KiB in 00:01:11
// Hits JIT assert in Release:
// Assertion failed 'cond == test->AsOp()->gtOp1' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Update flow graph early pass' (IL size 27; hash 0xade6b36b; FullOpts)
//
// File: D:\a\_work\1\s\src\coreclr\jit\fgopt.cpp Line: 5447
//
public class Runtime_103600
{
[Fact]
public static void TestEntryPoint()
{
ulong[] vr0 = default(ulong[]);
if (0 > vr0[0])
{
vr0 = vr0;
}
else
{
vr0 = new ulong[]{0};
}

vr0[0] = vr0[0];
}
}
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>