From 424c52af68cf302338dcb8aadf2ce21506df5ad3 Mon Sep 17 00:00:00 2001 From: Deepak Rajendrakumaran Date: Thu, 4 Apr 2024 17:42:02 -0700 Subject: [PATCH] Mirroring API change : https://github.com/dotnet/runtime/issues/98055#issuecomment-2032720254 --- .../System/Runtime/Intrinsics/ISimdVector_2.cs | 15 +++++++++++---- .../src/System/Runtime/Intrinsics/Vector128_1.cs | 9 +++++++-- .../src/System/Runtime/Intrinsics/Vector256_1.cs | 9 +++++++-- .../src/System/Runtime/Intrinsics/Vector512_1.cs | 9 +++++++-- .../src/System/Runtime/Intrinsics/Vector64_1.cs | 9 +++++++-- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs index 3dd8a7dc27cba..a88b5f0dec6a1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs @@ -553,11 +553,18 @@ static virtual bool TryCopyTo(TSelf vector, Span destination) // New Surface Area // - /// Checks if the MSB of any of the vector lanes is non zero. - /// The vector to check MSB. - /// true if has any lanes with a non-zero MSB otherwise, false if MSB is zero for all lanes />. + /// Checks if any of the vector lanes are equivalent to value. + /// The Vector. + /// The Value to check. + /// true if has any lanes equivalent to otherwise, false if none of the lanes are equivalent to />. /// The type of the elements in the vector () is not supported. - static abstract bool AnyMatches(TSelf vector); + static abstract bool Any(TSelf vector, T value); + + /// Checks if any of the vector lanes have All Bits set. + /// The Vector to check. + /// true if has any lanes with All Bits set otherwise, false if none of the lanes have All Bits set />. + /// The type of the elements in the vector () is not supported. + static abstract bool AnyWhereAllBitsSet(TSelf vector); static abstract int IndexOfLastMatch(TSelf vector); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs index 0cad8c6e04546..efa2f1f148b92 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs @@ -692,9 +692,14 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri // New Surface Area // - static bool ISimdVector, T>.AnyMatches(Vector128 vector) + static bool ISimdVector, T>.AnyWhereAllBitsSet(Vector128 vector) { - return (vector != Vector128.Zero); + return (Vector128.EqualsAny(vector, Vector128.AllBitsSet)); + } + + static bool ISimdVector, T>.Any(Vector128 vector, T value) + { + return (Vector128.EqualsAny(vector, Vector128.Create((T)value))); } static int ISimdVector, T>.IndexOfLastMatch(Vector128 vector) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs index d840f756d4eaa..af789a873535c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs @@ -682,9 +682,14 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri // New Surface Area // - static bool ISimdVector, T>.AnyMatches(Vector256 vector) + static bool ISimdVector, T>.AnyWhereAllBitsSet(Vector256 vector) { - return (vector != Vector256.Zero); + return (Vector256.EqualsAny(vector, Vector256.AllBitsSet)); + } + + static bool ISimdVector, T>.Any(Vector256 vector, T value) + { + return (Vector256.EqualsAny(vector, Vector256.Create((T)value))); } static int ISimdVector, T>.IndexOfLastMatch(Vector256 vector) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs index 83aa03d328763..c6e42c63c44f5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs @@ -682,9 +682,14 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri // New Surface Area // - static bool ISimdVector, T>.AnyMatches(Vector512 vector) + static bool ISimdVector, T>.AnyWhereAllBitsSet(Vector512 vector) { - return (vector != Vector512.Zero); + return (Vector512.EqualsAny(vector, Vector512.AllBitsSet)); + } + + static bool ISimdVector, T>.Any(Vector512 vector, T value) + { + return (Vector512.EqualsAny(vector, Vector512.Create((T)value))); } static int ISimdVector, T>.IndexOfLastMatch(Vector512 vector) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs index 7525a16fad582..241a2c294e4e3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs @@ -757,9 +757,14 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri // New Surface Area // - static bool ISimdVector, T>.AnyMatches(Vector64 vector) + static bool ISimdVector, T>.AnyWhereAllBitsSet(Vector64 vector) { - return (vector != Vector64.Zero); + return (Vector64.EqualsAny(vector, Vector64.AllBitsSet)); + } + + static bool ISimdVector, T>.Any(Vector64 vector, T value) + { + return (Vector64.EqualsAny(vector, Vector64.Create((T)value))); } static int ISimdVector, T>.IndexOfLastMatch(Vector64 vector)