From c3c5603902fd6e25ccc949460200469c4ecd5d79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 05:42:35 +0000 Subject: [PATCH 1/4] Initial plan From 6ef33f25947b7742686770246ebe5cff00703da4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 06:08:58 +0000 Subject: [PATCH 2/4] Fix JIT range analysis Multiply to correctly compute min/max across all endpoint products and add regression test for #124082 Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com> --- src/coreclr/jit/rangecheck.h | 29 ++++++++++++++----- .../JitBlue/Runtime_124082/Runtime_124082.cs | 28 ++++++++++++++++++ .../Runtime_124082/Runtime_124082.csproj | 11 +++++++ 3 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj diff --git a/src/coreclr/jit/rangecheck.h b/src/coreclr/jit/rangecheck.h index 9a56b80703154e..92886073a2c7bf 100644 --- a/src/coreclr/jit/rangecheck.h +++ b/src/coreclr/jit/rangecheck.h @@ -356,15 +356,28 @@ struct RangeOps static Range Multiply(const Range& r1, const Range& r2) { - return ApplyRangeOp(r1, r2, [](const Limit& a, const Limit& b) { - // For Mul we require both operands to be constant to produce a constant result. - if (b.IsConstant() && a.IsConstant() && - !CheckedOps::MulOverflows(a.GetConstant(), b.GetConstant(), CheckedOps::Signed)) - { - return Limit(Limit::keConstant, a.GetConstant() * b.GetConstant()); - } + if (!r1.IsConstantRange() || !r2.IsConstantRange()) + { return Limit(Limit::keUnknown); - }); + } + + int r1lo = r1.LowerLimit().GetConstant(); + int r1hi = r1.UpperLimit().GetConstant(); + int r2lo = r2.LowerLimit().GetConstant(); + int r2hi = r2.UpperLimit().GetConstant(); + + if (CheckedOps::MulOverflows(r1lo, r2lo, CheckedOps::Signed) || + CheckedOps::MulOverflows(r1lo, r2hi, CheckedOps::Signed) || + CheckedOps::MulOverflows(r1hi, r2lo, CheckedOps::Signed) || + CheckedOps::MulOverflows(r1hi, r2hi, CheckedOps::Signed)) + { + return Limit(Limit::keUnknown); + } + + int lo = min(min(r1lo * r2lo, r1lo * r2hi), min(r1hi * r2lo, r1hi * r2hi)); + int hi = max(max(r1lo * r2lo, r1lo * r2hi), max(r1hi * r2lo, r1hi * r2hi)); + assert(hi >= lo); + return Range(Limit(Limit::keConstant, lo), Limit(Limit::keConstant, hi)); } static Range ShiftRight(const Range& r1, const Range& r2, bool logical) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs new file mode 100644 index 00000000000000..17ff71551784d2 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs @@ -0,0 +1,28 @@ +// Generated by Fuzzlyn v3.3 on 2026-02-05 22:00:13 +// Run on X64 Windows +// Seed: 3325744140221827777-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86avx512fx64,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base +// Reduced from 64.4 KiB to 0.3 KiB in 00:01:42 +// Debug: Outputs -1 +// Release: Outputs 4294967295 +using System; +using Xunit; + +public class Runtime_124082 +{ + public static sbyte s_4 = 1; + public static byte[][] s_12 = new byte[][] + { + new byte[] + { + 1 + } + }; + + [Fact] + public static void TestEntryPoint() + { + byte[] vr9 = s_12[0]; + long vr10 = (ushort)s_4 * (sbyte)(-s_4); + Assert.Equal(-1L, vr10); + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj new file mode 100644 index 00000000000000..e562d2d441d936 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj @@ -0,0 +1,11 @@ + + + 1 + + + True + + + + + From a66dcd0932a1a3ddefaa9e615850d013233660d1 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 7 Feb 2026 07:10:46 +0100 Subject: [PATCH 3/4] Delete src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj --- .../JitBlue/Runtime_124082/Runtime_124082.csproj | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj deleted file mode 100644 index e562d2d441d936..00000000000000 --- a/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - 1 - - - True - - - - - From d96adbf31d0ea43127602892f1019373f8b0405a Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 7 Feb 2026 07:11:23 +0100 Subject: [PATCH 4/4] Update Runtime_124082.cs --- .../JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs index 17ff71551784d2..b27fd8588c7461 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_124082/Runtime_124082.cs @@ -1,9 +1,13 @@ +// 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 v3.3 on 2026-02-05 22:00:13 // Run on X64 Windows // Seed: 3325744140221827777-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86avx512fx64,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base // Reduced from 64.4 KiB to 0.3 KiB in 00:01:42 // Debug: Outputs -1 // Release: Outputs 4294967295 + using System; using Xunit;