From f077de01ff71242012de8b45a08ff504944fd460 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 25 Apr 2023 16:50:22 -0700 Subject: [PATCH] JIT: add ssa accounting to morph's div opts (#85332) RBO triggered a morph opt that cloned an SSA local, throwing off the SSA accounting. Fix by invoking the accounting helper after the morph expansion. Closes #85226. --- src/coreclr/jit/morph.cpp | 2 ++ .../JitBlue/Runtime_85226/Runtime_85226.cs | 36 +++++++++++++++++++ .../Runtime_85226/Runtime_85226.csproj | 8 +++++ 3 files changed, 46 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.csproj diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index ea5838af587..ffe382e1952 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -12152,6 +12152,8 @@ GenTree* Compiler::fgMorphModToSubMulDiv(GenTreeOp* tree) result->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED; #endif + optRecordSsaUses(result, compCurBB); + div->CheckDivideByConstOptimized(this); return result; diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.cs b/src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.cs new file mode 100644 index 00000000000..7aadc68a28d --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.cs @@ -0,0 +1,36 @@ +// 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 Xunit; + +// Generated by Fuzzlyn v1.5 on 2023-04-23 17:14:26 +// Run on X64 Windows +// Seed: 11244895947685014560 +// Reduced from 7.8 KiB to 0.3 KiB in 00:00:41 +// Hits JIT assert in Release: +// Assertion failed '!"SSA check failures"' in 'Program:M1()' during 'Redundant branch opts' (IL size 29; hash 0xaf510bb6; FullOpts) +// +// File: D:\a\_work\1\s\src\coreclr\jit\fgdiagnostic.cpp Line: 4392 +// +public class Runtime_85226 +{ + [Fact] + public static int Test() + { + M1(); + return 100; + } + + private static void M1() + { + for (int var0 = 0; var0 < -1; var0++) + { + short var1 = 2; + if (((ushort)((var0 % (var1 | 1)) % 0) < 0UL)) + { + return; + } + } + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.csproj new file mode 100644 index 00000000000..de6d5e08882 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_85226/Runtime_85226.csproj @@ -0,0 +1,8 @@ + + + True + + + + + -- GitLab