From 89ec998d5b561a780defc1694c2f1b718b91d637 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 00:29:13 +0000 Subject: [PATCH 1/3] Initial plan From abd63f9b08305203778e215992af8c5f6a808a93 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 00:42:58 +0000 Subject: [PATCH 2/3] Add disasm regression test for SingleToInt32Bits span loop codegen Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com> --- .../JitBlue/Runtime_130999/Runtime_130999.cs | 38 +++++++++++++++++++ .../Runtime_130999/Runtime_130999.csproj | 21 ++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs new file mode 100644 index 00000000000000..a49293f1a7d9a2 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs @@ -0,0 +1,38 @@ +// 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 System.Runtime.CompilerServices; +using Xunit; + +namespace Runtime_130999; + +public static class Runtime_130999 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + private static int SumBits(Span input) + { + int acc = 0; + + foreach (float f in input) + { + if (f < 0) + { + acc++; + } + + // X64-FULL-LINE: vmovd [[REG:[a-z0-9]+]], xmm{{[0-9]+}} + // X64-NOT: movss dword ptr [rsp + acc += BitConverter.SingleToInt32Bits(f); + } + + return acc; + } + + [Fact] + public static void TestEntryPoint() + { + float[] input = new[] { 1.25f, -2.5f, 3.75f, 4.125f }; + Assert.Equal(11796481, SumBits(input)); + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj new file mode 100644 index 00000000000000..5abc405b9fcdd8 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj @@ -0,0 +1,21 @@ + + + + true + + + True + True + + + + true + + + + + + + + + From 28a3db19e321a5ad1bcbd4cdda119cbb69fe880f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 00:45:05 +0000 Subject: [PATCH 3/3] Refine SingleToInt32Bits disasm regression coverage Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com> --- .../JitBlue/Runtime_130999/Runtime_130999.cs | 32 +++++++++++++++++-- .../Runtime_130999/Runtime_130999.csproj | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs index a49293f1a7d9a2..5b042dcb85e60d 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.cs @@ -9,6 +9,23 @@ namespace Runtime_130999; public static class Runtime_130999 { + private static int Expected(float[] input) + { + int acc = 0; + + foreach (float f in input) + { + if (f < 0) + { + acc++; + } + + acc += BitConverter.SingleToInt32Bits(f); + } + + return acc; + } + [MethodImpl(MethodImplOptions.NoInlining)] private static int SumBits(Span input) { @@ -22,17 +39,26 @@ private static int SumBits(Span input) } // X64-FULL-LINE: vmovd [[REG:[a-z0-9]+]], xmm{{[0-9]+}} + // X64-FULL-LINE-NEXT: add {{[a-z0-9]+}}, [[REG]] // X64-NOT: movss dword ptr [rsp acc += BitConverter.SingleToInt32Bits(f); } + // X64-FULL-LINE: ret return acc; } [Fact] - public static void TestEntryPoint() + public static void Test() { - float[] input = new[] { 1.25f, -2.5f, 3.75f, 4.125f }; - Assert.Equal(11796481, SumBits(input)); + float[] empty = Array.Empty(); + float[] single = new[] { -2.5f }; + float[] mixed = new[] { 1.25f, -2.5f, 3.75f, 4.125f }; + float[] edge = new[] { float.NaN, float.PositiveInfinity, float.NegativeInfinity, float.Epsilon, -float.Epsilon }; + + Assert.Equal(Expected(empty), SumBits(empty)); + Assert.Equal(Expected(single), SumBits(single)); + Assert.Equal(Expected(mixed), SumBits(mixed)); + Assert.Equal(Expected(edge), SumBits(edge)); } } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj index 5abc405b9fcdd8..a80dd6fcfafc78 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj +++ b/src/tests/JIT/Regression/JitBlue/Runtime_130999/Runtime_130999.csproj @@ -9,6 +9,7 @@ + true