From e8ed303fff76f4877ad63d1cf53520fb25e71238 Mon Sep 17 00:00:00 2001 From: David Hartglass Date: Thu, 17 Sep 2026 11:34:11 -0700 Subject: [PATCH 1/3] fix and regression tests --- src/coreclr/jit/hwintrinsic.cpp | 10 ++- .../Runtime_134150/Runtime_134150.cs | 70 +++++++++++++++++++ .../Runtime_134150/Runtime_134150.csproj | 12 ++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs create mode 100644 src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index d84f1dfa732107..ba0a932593832c 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -2928,10 +2928,18 @@ GenTree* Compiler::impXplatIntrinsic(NamedIntrinsic intrinsic, switch (intrinsic) { case NI_Vector_Abs: + { + potentiallyNotSupported = varTypeIsSigned(simdBaseType); + break; + } + case NI_Vector_IsNegative: case NI_Vector_IsPositive: { - potentiallyNotSupported = varTypeIsSigned(simdBaseType); + // The 256-bit signed integer comparisons used for sign checks require AVX2. + // Floating-point sign checks reinterpret the lanes as signed integers and use + // the same comparison path. + potentiallyNotSupported = !varTypeIsUnsigned(simdBaseType); break; } diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs new file mode 100644 index 00000000000000..a92d56c9eb4181 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs @@ -0,0 +1,70 @@ +// 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 System.Runtime.Intrinsics; +using Xunit; + +public class Runtime_134150 +{ + [Theory] + [InlineData(false)] + [InlineData(true)] + public static void Single(bool positive) + { + float[] values = + [ + 0.0f, -0.0f, 1.0f, -1.0f, + float.Epsilon, -float.Epsilon, float.PositiveInfinity, float.NegativeInfinity, + BitConverter.Int32BitsToSingle(0x7FC00000), BitConverter.Int32BitsToSingle(unchecked((int)0xFFC00000)), + BitConverter.Int32BitsToSingle(0x7F800001), BitConverter.Int32BitsToSingle(unchecked((int)0xFF800001)), + float.MaxValue, float.MinValue, 2.0f, -2.0f + ]; + + for (int offset = 0; offset < values.Length; offset += Vector256.Count) + { + Vector256 vector = Vector256.Create(values.AsSpan(offset)); + Vector256 result = (positive ? IsPositive(vector) : IsNegative(vector)).AsInt32(); + + for (int i = 0; i < Vector256.Count; i++) + { + bool negative = BitConverter.SingleToInt32Bits(values[offset + i]) < 0; + Assert.Equal(negative != positive ? -1 : 0, result.GetElement(i)); + } + } + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public static void Double(bool positive) + { + double[] values = + [ + 0.0, -0.0, 1.0, -1.0, + double.Epsilon, -double.Epsilon, double.PositiveInfinity, double.NegativeInfinity, + BitConverter.Int64BitsToDouble(0x7FF8000000000000), BitConverter.Int64BitsToDouble(unchecked((long)0xFFF8000000000000)), + BitConverter.Int64BitsToDouble(0x7FF0000000000001), BitConverter.Int64BitsToDouble(unchecked((long)0xFFF0000000000001)), + double.MaxValue, double.MinValue, 2.0, -2.0 + ]; + + for (int offset = 0; offset < values.Length; offset += Vector256.Count) + { + Vector256 vector = Vector256.Create(values.AsSpan(offset)); + Vector256 result = (positive ? IsPositive(vector) : IsNegative(vector)).AsInt64(); + + for (int i = 0; i < Vector256.Count; i++) + { + bool negative = BitConverter.DoubleToInt64Bits(values[offset + i]) < 0; + Assert.Equal(negative != positive ? -1L : 0L, result.GetElement(i)); + } + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector256 IsNegative(Vector256 vector) => Vector256.IsNegative(vector); + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector256 IsPositive(Vector256 vector) => Vector256.IsPositive(vector); +} diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj new file mode 100644 index 00000000000000..d786c261bf14af --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj @@ -0,0 +1,12 @@ + + + 1 + true + True + + + + + + + From faceab23d88bbb9326863baec7807987e410775f Mon Sep 17 00:00:00 2001 From: David Hartglass Date: Thu, 17 Sep 2026 11:58:42 -0700 Subject: [PATCH 2/3] simpler test case --- .../Runtime_134150/Runtime_134150.cs | 60 ++----------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs index a92d56c9eb4181..7f5f532777ab5d 100644 --- a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs +++ b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs @@ -1,70 +1,22 @@ // 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 System.Runtime.Intrinsics; using Xunit; public class Runtime_134150 { - [Theory] - [InlineData(false)] - [InlineData(true)] - public static void Single(bool positive) + [Fact] + public static void TestEntryPoint() { - float[] values = - [ - 0.0f, -0.0f, 1.0f, -1.0f, - float.Epsilon, -float.Epsilon, float.PositiveInfinity, float.NegativeInfinity, - BitConverter.Int32BitsToSingle(0x7FC00000), BitConverter.Int32BitsToSingle(unchecked((int)0xFFC00000)), - BitConverter.Int32BitsToSingle(0x7F800001), BitConverter.Int32BitsToSingle(unchecked((int)0xFF800001)), - float.MaxValue, float.MinValue, 2.0f, -2.0f - ]; - - for (int offset = 0; offset < values.Length; offset += Vector256.Count) - { - Vector256 vector = Vector256.Create(values.AsSpan(offset)); - Vector256 result = (positive ? IsPositive(vector) : IsNegative(vector)).AsInt32(); - - for (int i = 0; i < Vector256.Count; i++) - { - bool negative = BitConverter.SingleToInt32Bits(values[offset + i]) < 0; - Assert.Equal(negative != positive ? -1 : 0, result.GetElement(i)); - } - } - } - - [Theory] - [InlineData(false)] - [InlineData(true)] - public static void Double(bool positive) - { - double[] values = - [ - 0.0, -0.0, 1.0, -1.0, - double.Epsilon, -double.Epsilon, double.PositiveInfinity, double.NegativeInfinity, - BitConverter.Int64BitsToDouble(0x7FF8000000000000), BitConverter.Int64BitsToDouble(unchecked((long)0xFFF8000000000000)), - BitConverter.Int64BitsToDouble(0x7FF0000000000001), BitConverter.Int64BitsToDouble(unchecked((long)0xFFF0000000000001)), - double.MaxValue, double.MinValue, 2.0, -2.0 - ]; - - for (int offset = 0; offset < values.Length; offset += Vector256.Count) - { - Vector256 vector = Vector256.Create(values.AsSpan(offset)); - Vector256 result = (positive ? IsPositive(vector) : IsNegative(vector)).AsInt64(); - - for (int i = 0; i < Vector256.Count; i++) - { - bool negative = BitConverter.DoubleToInt64Bits(values[offset + i]) < 0; - Assert.Equal(negative != positive ? -1L : 0L, result.GetElement(i)); - } - } + Assert.Equal(Vector256.Zero, IsNegative(Vector256.Zero).AsInt64()); + Assert.Equal(Vector256.AllBitsSet, IsPositive(Vector256.Zero).AsInt32()); } [MethodImpl(MethodImplOptions.NoInlining)] - private static Vector256 IsNegative(Vector256 vector) => Vector256.IsNegative(vector); + private static Vector256 IsNegative(Vector256 vector) => Vector256.IsNegative(vector); [MethodImpl(MethodImplOptions.NoInlining)] - private static Vector256 IsPositive(Vector256 vector) => Vector256.IsPositive(vector); + private static Vector256 IsPositive(Vector256 vector) => Vector256.IsPositive(vector); } From da5205486719b16cd11468922d36903b9d63df1a Mon Sep 17 00:00:00 2001 From: David Hartglass Date: Thu, 17 Sep 2026 15:25:49 -0700 Subject: [PATCH 3/3] remove unnecessary test --- .../Runtime_134150/Runtime_134150.cs | 22 ------------------- .../Runtime_134150/Runtime_134150.csproj | 12 ---------- 2 files changed, 34 deletions(-) delete mode 100644 src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs delete mode 100644 src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs deleted file mode 100644 index 7f5f532777ab5d..00000000000000 --- a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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 System.Runtime.Intrinsics; -using Xunit; - -public class Runtime_134150 -{ - [Fact] - public static void TestEntryPoint() - { - Assert.Equal(Vector256.Zero, IsNegative(Vector256.Zero).AsInt64()); - Assert.Equal(Vector256.AllBitsSet, IsPositive(Vector256.Zero).AsInt32()); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static Vector256 IsNegative(Vector256 vector) => Vector256.IsNegative(vector); - - [MethodImpl(MethodImplOptions.NoInlining)] - private static Vector256 IsPositive(Vector256 vector) => Vector256.IsPositive(vector); -} diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj b/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj deleted file mode 100644 index d786c261bf14af..00000000000000 --- a/src/tests/JIT/HardwareIntrinsics/General/Regression/Runtime_134150/Runtime_134150.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - 1 - true - True - - - - - - -