Skip to content

Don't update side-effects in a statement that doesn't exist #113351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all 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
10 changes: 8 additions & 2 deletions src/coreclr/jit/rangecheckcloning.cpp
Original file line number Diff line number Diff line change
@@ -345,7 +345,12 @@ static BasicBlock* optRangeCheckCloning_DoClone(Compiler* comp,
// it happens when we emit BBJ_COND(0 >= 0) fake block (for simplicity)
comp->gtUpdateStmtSideEffects(lowerBndBb->lastStmt());
}
comp->gtUpdateStmtSideEffects(upperBndBb->lastStmt());
if (upperBndBb->lastStmt() != nullptr)
{
// In rare cases, upperBndBb can also be folded into an empty block
// by fgMorphBlockStmt
comp->gtUpdateStmtSideEffects(upperBndBb->lastStmt());
}

// All blocks must be in the same EH region
assert(BasicBlock::sameEHRegion(prevBb, lowerBndBb));
@@ -395,7 +400,8 @@ class BoundsChecksVisitor final : public GenTreeVisitor<BoundsChecksVisitor>

fgWalkResult PostOrderVisit(GenTree** use, GenTree* user)
{
if ((*use)->OperIs(GT_BOUNDS_CHECK))
// For now, we only handle SCK_RNGCHK_FAIL
if ((*use)->OperIs(GT_BOUNDS_CHECK) && ((*use)->AsBoundsChk()->gtThrowKind == SCK_RNGCHK_FAIL))
{
m_boundsChks->Push(BoundCheckLocation(m_stmt, use, m_stmtIdx));
}
30 changes: 30 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_113334/Runtime_113334.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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 v2.4 on 2025-03-09 18:07:26
// Run on X86 Windows
// Seed: 1821229397629005810-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86bmi1,x86bmi2,x86fma,x86lzcnt,x86pclmulqdq,x86popcnt,x86sse,x86sse2,x86sse3,x86sse41,x86sse42,x86ssse3,x86x86base
// Reduced from 126.0 KiB to 0.5 KiB in 00:02:28
// Hits JIT assert in Release:
// Assertion failed 'use != nullptr' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Clone blocks with range checks' (IL size 62; hash 0xade6b36b; FullOpts)

using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using Xunit;

public class Runtime_113334
{
[Fact]
public static void Problem()
{
if (Fma.IsSupported)
{
float[] vr8 = new float[]
{
0
};
var vr9 = Vector128.Create<float>(0);
Fma.MultiplyAddNegatedScalar(vr9, Vector128.Create(vr8[0], vr8[0], vr8[0], vr8[0]), Sse.CompareScalarEqual(Vector128.Create<float>(vr8[0]), Vector128.CreateScalar(vr8[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>